object variable or with block variable not set

Pete Morris

Registered User.
Local time
Today, 11:29
Joined
Mar 31, 2003
Messages
38
Hi,

I am trying to get this code to work for cascading combo boxes on a form, but keep getting the above error.
Could someone look at the code and let me know what obvious bit I'm missing.
I'm new to code and have hashed this from an example to try to get it to work on my database.
Also would this work if there was also a not in list event procedure on the same cbobox


Private Sub ClientName_AfterUpdate()
Dim cboProjectCode As AccessObject
Dim cboClientName As AccessObject
'cascading cbo to align the users choices against relevant items available
With cboProjectCode
Set cboProjectCode.RowSource = "Select tblClientNameLookup.ClientName " & _
"FROM tblClientNameLookup " & _
"WHERE tblClientNameLookup.ClientName = '" & cboClientName.Value & "' " & _
"ORDER BY tblClientNameLookup.ProjectCode;"
End With
End Sub

Thanks in hope,

Pete.
 
Try simplifying your code to something like:
Code:
Private Sub ClientName_AfterUpdate()
'cascading cbo to align the users choices against relevant items available
Me.cboProjectCode.RowSource = "Select tblClientNameLookup.ClientName " & _
"FROM tblClientNameLookup " & _
"WHERE tblClientNameLookup.ClientName = '" & cboClientName & "' " & _
"ORDER BY tblClientNameLookup.ProjectCode;"
End Sub
 

Users who are viewing this thread

Back
Top Bottom