object variable

  • Thread starter Thread starter landewe
  • Start date Start date
L

landewe

Guest
Hi,
I'm new to the Access world and not sure whether this forum is appropriate, but I need some help and thought I would try. I'm working on a database for a professor of mine. I'm nearing completion, but trying to work out a few bugs for the forms. I am getting an error stating "Object variable or With block variable not set". Could someone explain this to me in laymen's terms? I can't seem to find the answer.

Thanks
 
This forum's appropriate, post the code that's producing the error.
 
Below is a link to a site that will give you more information.

If you're anything like me, the most frustrating part of this error is that you probably aren't using a with block.

As far as I can tell this error is caused by not specifying an optional argument when calling a procedure. (Kind of funny if you think about the word "optional")

Anyway, hope this helps
http://support.microsoft.com/support/kb/articles/Q162/5/34.asp?LN=EN-US&SD=gn&FR=0&qry=Object%20variable%20or%20With%20block%20variable%20not%20set&rnk=2&src=DHCS_MSPSS_gn_SRCH&SPR =ACC97
 
Here's the code. As I said before, I'm just beginning, so there could be some basic errors. Basically I'm trying to get a message box to display if no records are returned from the query. Any help would be much appreciated!
Thanks.

Private Sub cmdEconomic_Click()
On Error GoTo Err_cmdEconomic_Click

Dim SPF As CurrentData
Dim Economic As Recordset
Dim StrMsg As String

StrMsg = "Search too narrow. Please modify your selections to broaden your search."

DoCmd.OpenQuery "qryQBFEconomic"
DoCmd.Close acQuery, "qryQBFEconomic"

Set Economic = SPF.OpenRecordset("qryQBFEconomic")
Economic.MoveFirst
If Dollars.EOF = Yes Then
MsgBox (StrMsg)
Else
DoCmd.OpenForm "frmEconomic", , "qryQBFEconomic"
End If

Exit_cmdEconomic_Click:
Exit Sub

Err_cmdEconomic_Click:
MsgBox Err.Description
Resume Exit_cmdEconomic_Click

End Sub
 
hi,

you don't seem to have created dollars anywhere, which may not be the problem but as you're treating as a recordset it may well be, also - why are you opening and closing the query at the start? If it's to check that it exists then you can just use an error handler to deal with it

HTH

Drew
 
just asking where is DOLLARS, in the form or economic recordset. if in form then make it Me!Dollars. if in recordset try Economic!Dollars
 

Users who are viewing this thread

Back
Top Bottom