Compile error on Combo box: Method or data member not found

P

Peter Stone

Novice

I have a combo box on the header of my form that selects travel
destinations. It worked fine until I changed the name of a field in the table
(and in the code).

Now when I try to select a destination in the combo box I get a compile error:
Method or data member not found

Please see the first Else statement below (I’ve indicated the problem in
capitals).

Thanks for the help
Peter

Private Sub cboDestination_AfterUpdate()
Dim resp, msg As String
Me.lstSelectRecord.Requery
Me.RecordsetClone.FindFirst _
"[LocalDestinationID] = " & Me![cboDestination]

If Not Me.RecordsetClone.NoMatch Then
'go to the first record in the set
Me.Bookmark = Me.RecordsetClone.Bookmark
Else
'ask if they want to add a new record
msg = "No records. Do you want to add a new record?"
resp = MsgBox(msg, vbQuestion + vbYesNo, "Add Record")
If resp = vbYes Then
'go to a new record
DoCmd.GoToRecord , , acNewRec
PROBLEM BELOW, COMPILE ERROR CAN’T FIND LocalDestinationID
Me.LocalDestinationID = Me.cboDestination

Else
'go to the first record
DoCmd.GoToRecord , , acFirst
Me.cboDestination = Me.LocalDestinationID
End If
End If
Me.Refresh
End Sub
 
G

Graham Mandeno

Hi Peter

Are you sure that LocalDestinationID is a field in your form's RecordSource?

Have you tried using an exclamation instead of a dot?
Me!LocalDestinationID = Me.cboDestination

It's a good idea to check all your code for compilation errors by compiling
the entire project, rather than having things grind to a halt at run-time.
Do this with Debug>Compile from the VB code window.
 
P

Peter Stone

Thanks Graham
The exclamation fixed it. I would never have tried that, because the code
that worked with the previous field name had a dot.

Also thanks for the tip about compiling--this forum is the only way I have
of getting help and these little tips are invaluable.

Peter
 

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