Help with this code

A

Ayo

I am getting a "variable not defined" error. I didn't have this problem
before. Any ideas?

Private Sub cmbSiteNumber_AfterUpdate()
On Error GoTo ErrHandler
Set rs = Forms!frmSiteConstruction_Information.Recordset.Clone
rs.FindFirst "[SITE NUMBER]='" & Me.cmbSiteNumber & "'" & ""
If Not rs.EOF Then Forms!frmSiteConstruction_Information.Bookmark =
rs.Bookmark
Exit Sub

ErrHandler:
MsgBox "Error in cmbSiteNumber_AfterUpdate() in" & vbCrLf & Me.Name & "
form." & vbCrLf & _
vbCrLf & "Error#" & Err.Number & vbCrLf & Err.Description
Err.Clear

End Sub
 
A

akphidelt

I'm not sure if this is the cause of the problem... but i think you need to
declare rs as a DAO.Recordset variable.

So the first line after the private sub would be

Dim rs as DAO.Recordset
 
A

Ayo

Thanks. That seem to work.

akphidelt said:
I'm not sure if this is the cause of the problem... but i think you need to
declare rs as a DAO.Recordset variable.

So the first line after the private sub would be

Dim rs as DAO.Recordset



Ayo said:
I am getting a "variable not defined" error. I didn't have this problem
before. Any ideas?

Private Sub cmbSiteNumber_AfterUpdate()
On Error GoTo ErrHandler
Set rs = Forms!frmSiteConstruction_Information.Recordset.Clone
rs.FindFirst "[SITE NUMBER]='" & Me.cmbSiteNumber & "'" & ""
If Not rs.EOF Then Forms!frmSiteConstruction_Information.Bookmark =
rs.Bookmark
Exit Sub

ErrHandler:
MsgBox "Error in cmbSiteNumber_AfterUpdate() in" & vbCrLf & Me.Name & "
form." & vbCrLf & _
vbCrLf & "Error#" & Err.Number & vbCrLf & Err.Description
Err.Clear

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top