| | |
object variable or with block variable not set
![]() |
•
•
Join Date: Feb 2006
Posts: 9
Reputation:
Solved Threads: 0
starting to create a database and new at this. I keep getting the message 'object variable or with block variable not set'. I don't know why I get this error or how to check which line or area in code is wrong. Please help!
Option Compare Database
Option Explicit
Private Sub Save_IP_Type_Button_Click()
On Error GoTo Error_Sub
Dim inputTypeID As Variant
Dim inputType As Variant
inputTypeID = Me!IPTypeID
inputType = Me!IPType
If IsNull(inputTypeID) Then
MsgBox "You must enter an IP acronym!", vbExclamation, "No Acronym Entered"
ElseIf IsNull(inputType) Then
MsgBox "You must enter an IP type!", vbExclamation, "No Type Entered"
Else
Dim table As Recordset
Set table = globalDatabase.OpenRecordset("SELECT * FROM IPTypeLookup WHERE IPTypeID='" & inputTypeID & "';", dbOpenForwardOnly)
If Not table.BOF And table.EOF Then ' If the acronym entered is already in use
table.Close
MsgBox "IP acronym is already in use!", vbExclamation, "Duplicate IP Acronym"
Exit Sub
End If
table.Close
Set table = globalDatabase.OpenRecordset("SELECT * FROM IPTypeLookup WHERE Type='" & inputType & "';", dbOpenForwardOnly)
If table.BOF And table.EOF Then ' If the IP Type entered does not exist
table.Close
Set table = globalDatabase.OpenRecordset("IPTypeLookup", dbOpenTable)
table.AddNew
table!IPTypeID = inputTypeID
table!Type = inputType
table.Update
table.Close
DoCmd.Close acForm, Me.Name
Else ' If the IP Type entered does exist
table.Close
MsgBox "IP type already exists!", vbExclamation, "Duplicate IP Type"
End If
End If
Exit_Sub:
Exit Sub
Error_Sub:
MsgBox err.Description
Resume Exit_Sub
End Sub
Option Compare Database
Option Explicit
Private Sub Save_IP_Type_Button_Click()
On Error GoTo Error_Sub
Dim inputTypeID As Variant
Dim inputType As Variant
inputTypeID = Me!IPTypeID
inputType = Me!IPType
If IsNull(inputTypeID) Then
MsgBox "You must enter an IP acronym!", vbExclamation, "No Acronym Entered"
ElseIf IsNull(inputType) Then
MsgBox "You must enter an IP type!", vbExclamation, "No Type Entered"
Else
Dim table As Recordset
Set table = globalDatabase.OpenRecordset("SELECT * FROM IPTypeLookup WHERE IPTypeID='" & inputTypeID & "';", dbOpenForwardOnly)
If Not table.BOF And table.EOF Then ' If the acronym entered is already in use
table.Close
MsgBox "IP acronym is already in use!", vbExclamation, "Duplicate IP Acronym"
Exit Sub
End If
table.Close
Set table = globalDatabase.OpenRecordset("SELECT * FROM IPTypeLookup WHERE Type='" & inputType & "';", dbOpenForwardOnly)
If table.BOF And table.EOF Then ' If the IP Type entered does not exist
table.Close
Set table = globalDatabase.OpenRecordset("IPTypeLookup", dbOpenTable)
table.AddNew
table!IPTypeID = inputTypeID
table!Type = inputType
table.Update
table.Close
DoCmd.Close acForm, Me.Name
Else ' If the IP Type entered does exist
table.Close
MsgBox "IP type already exists!", vbExclamation, "Duplicate IP Type"
End If
End If
Exit_Sub:
Exit Sub
Error_Sub:
MsgBox err.Description
Resume Exit_Sub
End Sub
•
•
Join Date: Jan 2006
Posts: 275
Reputation:
Solved Threads: 11
You really posted this in the wrong forum, but i am sure someone will move it for you.
My vb is rusty but i dont see acForm declared anywhere. What is it? Seems like its your problem.
What development tool are you using? Visual Studio? What version? Let me know and i can tell you how to debug. The second most important thing a developer HAS to know, is how to debug correctly. It saves hours of frustration and time, as no one can write a program bug free first time (unless it is a mickey mouse one that has no real value).
•
•
•
•
DoCmd.Close acForm, Me.Name
What development tool are you using? Visual Studio? What version? Let me know and i can tell you how to debug. The second most important thing a developer HAS to know, is how to debug correctly. It saves hours of frustration and time, as no one can write a program bug free first time (unless it is a mickey mouse one that has no real value).
•
•
Join Date: Jan 2006
Posts: 275
Reputation:
Solved Threads: 11
oh wow. now you are pushing my memory limits 
I still think the problem is the acForm. It isnt declared anywhere.
I think you can put a break point in access 97 on the line of code for debugging?
either that or put a message box on the line before to show the value of acForm or one of its properties. I think it is null

I still think the problem is the acForm. It isnt declared anywhere.
I think you can put a break point in access 97 on the line of code for debugging?
either that or put a message box on the line before to show the value of acForm or one of its properties. I think it is null
![]() |
Similar Threads
- runtime error 91 object variable or With block variable not set (Visual Basic 4 / 5 / 6)
- 'Object variable or With block variable not set' Error (ASP.NET)
- Pointers (archived tutorial) (C++)
- VB.NET Web service using COM component - "Object variable or With block variable ..." (VB.NET)
Other Threads in the Community Introductions Forum
- Previous Thread: First posting
- Next Thread: This is Rahul newbie here
| Thread Tools | Search this Thread |
adsense aladar amatueurgrapicdesigner beginner business c# c#picturebox c++ champlain college contentwriting copywriter dba deleterectangle dheeraj experiences forensic givemetehcodez helloall internet internetmarketing introduction introductory itservices jauhari java lahore.civilengineer market marketing mca multiplerectangle naveen newbie newcomernote newgirl nigeria noob note oil online peertopeervideostreaming pekdi pictureboxselectobject prankerio profanitytest programmer projects research seo seoservices share shiva..... sqlserver stillnew student suthar tester traffic typhoon waliya'sgratituteandrequest. web webcam webdesign welcomenote wllu wolf wordpresstheme






