how to reference a uniqueidentifier

E

Eric

I have an access 2007 based application and I need to be able to open a form
based on a uniqueidentifier, the guid is used here as the primary key.

I have this now:

Dim strcriteria as string

strcriteria = "[ID]= '" & Me.ID & "'"

DoCmd.OpenForm ("myform"),,, strcriteria

When I open the form I get this error:

Syntax Error: Converting from a Character String to Uniqueidentifier

Does anyone knows what the correct syntax should be in this case?
 
V

vanderghast

Note that my previous answer was assuming that your ID was a GUID. If it is
an autonumber, simply remove the single quotes, leaving:

if IsNull(Me.ID) then
strCriteria=vbNullString
else
strCriteria = "[ID]=" & Me.ID
end if


Vanderghast, Access MVP
 

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