Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SET QUERY IN VISUAL BASICS

Status
Not open for further replies.

DIVINEDAR0956

IS-IT--Management
Aug 15, 2002
95
0
0
US
I have the following procedure and it gives the error message "OBJECT VARIABLE OR WITH BLOCK VARIABLE NOT SET"

Private Sub Command109_Click()
On Error GoTo Err_Command109_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim obCheckProject As Object
Dim obCheckStoreProject As Object
Dim stDocNameA As String

stDocName = "frEditTaskHours"
stDocNameA = "frStoreProject"
Set obCheckProject = "qryCheckProject"
Set obCheckStoreProject = "qryCheckStoreProject"

stLinkCriteria = "[JOBNUMBER]=" & "'" & Me![JobNumber] & "'"

DoCmd.OpenQuery "qryCheckProject", acViewNormal, acEdit
DoCmd.OpenQuery "qryCheckStoreProject", acViewNormal, acEdit

If obCheckProject = obCheckStoreProject Then
DoCmd.OpenQuery "DltProject", acViewNormal, acEdit
DoCmd.OpenQuery "apStoreProjectToProject", acViewNormal, acEdit
Else
DoCmd.OpenQuery "apProjectToStoreProject", acViewNormal, acEdit
End If

DoCmd.Close acQuery, "DltProjectFromStoreProject", acSaveYes
DoCmd.Close acQuery, "apProjectToStoreProject", acSaveYes

DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.OpenForm stDocNameA, , , stLinkCriteria

Exit_Command109_Click:
Exit Sub

Err_Command109_Click:
MsgBox Err.DESCRIPTION
Resume Exit_Command109_Click

End Sub


If someone can tell me what's my problem to get this procedure to run without the error would be most appreciated. Also if there is an easier way to rewrite this procedure please advise.



Darlene Sippio
dsippio@comtechsystems.com
 
Hi,
I have seen this before and it's not your code (though I didn't look to close at it), but your program can't see the access data object. Get a short query statement to work first then expand.
Regards,
John

*********************
John Nyhart
*********************
 
I'm sorry John but I just did this as a step by step thing hoping it would work. I did not pull this code from anywhere. Some of it believe or not I just took a chance on. Thank you though. Please give example of short query statement. I'm afraid that's something I've never worked with yet.

Darlene Sippio
dsippio@comtechsystems.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top