docmd.Openform not working with text

R

Rich

I need some help please - I have been playing with this code in my form

for two days now. I have a form the shows a few field of a table. I
want to click on a unique identifier in the form and open another form
that shows the full record of the identifier I clicked on. I have other

places I am using this with ID fields that are numbers but I can't seem

to get it to work with text and I have no idea why. Here is my code:

Private Sub ID_DblClick(Cancel As Integer)
If Not Me.NewRecord Then

DoCmd.OpenForm "Carriers", , , "ID = 'Me.ID'"

End If

End Sub

When I have the code setup like shown above it opens the form with no
records. ID is a unique ID that is text. I should qualify all of this
by saying that this is all being done in a Microsfot Access Project.

Thanks in advance for all the help.
 
J

J. Goddard

You have the syntax wrong. Try this (assuming me.id is numeric)

DoCmd.OpenForm "Carriers", , , "ID = " & Me.ID

If me!ID is character, use this:

DoCmd.OpenForm "Carriers", , , "ID = '" & Me.ID & "'"

HTH
John
 
R

Rich

Perfect...you are a life saver...



J. Goddard said:
You have the syntax wrong. Try this (assuming me.id is numeric)

DoCmd.OpenForm "Carriers", , , "ID = " & Me.ID

If me!ID is character, use this:

DoCmd.OpenForm "Carriers", , , "ID = '" & Me.ID & "'"

HTH
John
 

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