943,965 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Feb 26th, 2006
0

object variable or with block variable not set

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
aoude is offline Offline
9 posts
since Feb 2006
Feb 26th, 2006
0

Re: object variable or with block variable not set

You really posted this in the wrong forum, but i am sure someone will move it for you.
Quote ...
DoCmd.Close acForm, Me.Name
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).
Reputation Points: 26
Solved Threads: 11
Posting Whiz in Training
f1 fan is offline Offline
275 posts
since Jan 2006
Feb 26th, 2006
0

Re: object variable or with block variable not set

Thank you for getting back to me...I am creating a database using ACCESS 97.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
aoude is offline Offline
9 posts
since Feb 2006
Feb 26th, 2006
0

Re: object variable or with block variable not set

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
Reputation Points: 26
Solved Threads: 11
Posting Whiz in Training
f1 fan is offline Offline
275 posts
since Jan 2006
Feb 26th, 2006
0

Re: object variable or with block variable not set

WOW you're fast...I will try to do what you have advised me...I will let you know what happens! Thanks!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
aoude is offline Offline
9 posts
since Feb 2006
Feb 26th, 2006
0

Re: object variable or with block variable not set

I didn't what you advised but I keep getting the same message
Reputation Points: 10
Solved Threads: 0
Newbie Poster
aoude is offline Offline
9 posts
since Feb 2006
Feb 26th, 2006
0

Re: object variable or with block variable not set

does it highlight or give you a line number?
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Feb 26th, 2006
0

Re: object variable or with block variable not set

it highlights
Reputation Points: 10
Solved Threads: 0
Newbie Poster
aoude is offline Offline
9 posts
since Feb 2006
Feb 26th, 2006
0

Re: object variable or with block variable not set

mkay... and what line does it highlight?
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Feb 26th, 2006
0

Re: object variable or with block variable not set

it only highlights when I change something in the code...either put a line break etc...but if I just run the code I just get a message box 'object variable or with block variable not set'...I don't know how to check where the bug is exactly...I know this sounds really stupid...sorry!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
aoude is offline Offline
9 posts
since Feb 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Community Introductions Forum Timeline: First posting
Next Thread in Community Introductions Forum Timeline: This is Rahul newbie here





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC