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.
 
R

RoyVidar

Rich said:
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.

You appear to be stuffing the reference into the string, while you
probably need the value.

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

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