GUID as List Box Bound column for navigation...

G

Guest

when i navigate records on a form the list box should highlight the correct
record.

With an integer as the record id, the following worked just fine...

Private Sub Form_Current()
lstCompanies = [id]
End Sub

but lstCompanies = [idGUID] does not function properly and the row is not
highlighted. I have tried CAST(GUID AS nchar(36)) to use it as a text
string, but still no luck (values are duplicated)

Any ideas to nicely highlight the proper row in the list box for the
appropiate record in the form?

thank you

SQL Server back end
MS Access Project 2003 (ADP)
 
G

Guest

You are correct when you have to convert it to a stringvalue.

Try something like this:

Private Sub Form_Current()
Dim strGUID As String

strGUID = StringFromGUID(lstCompanies)
lstCompanies = strGUID

End Sub

hth
 
G

Guest

Thanks Maurice, but this is what prints in the immediate window:

GUID: ????????

so apparantly, my StringFromGUID function doesn't work properly... Any
ideas why i can't get a string?

I am using a table-valued function to get the data; i verified that idGUID
is 'uniqueidentifier' in the SQL table (i also tried accessing the table
rather than the function to see if that was the problem)

Maurice said:
You are correct when you have to convert it to a stringvalue.

Try something like this:

Private Sub Form_Current()
Dim strGUID As String

strGUID = StringFromGUID(lstCompanies)
lstCompanies = strGUID

End Sub

hth
--
Maurice Ausum


rogge said:
when i navigate records on a form the list box should highlight the correct
record.

With an integer as the record id, the following worked just fine...

Private Sub Form_Current()
lstCompanies = [id]
End Sub

but lstCompanies = [idGUID] does not function properly and the row is not
highlighted. I have tried CAST(GUID AS nchar(36)) to use it as a text
string, but still no luck (values are duplicated)

Any ideas to nicely highlight the proper row in the list box for the
appropiate record in the form?

thank you

SQL Server back end
MS Access Project 2003 (ADP)
 
G

Guest

Rather than use the actual GUID, i created a calculated field, txtGUID, in
the table for navigation purposes. this cleared many issues... I used the
cast function and named the field txtGUID

it also seems that Access convertes GUDS to strings for the controls; and
this was causing the difficulty....

this is the a from using StringFromGUID:
{guid {E6919771-152B-463D-AC48-FFA22AB088FC}}

one needs create the string like so in Access:
Mid(StringFromGUID([idGUID]), 8, 36)
E6919771-152B-463D-AC48-FFA22AB088FC
 
G

Guest

Maurice:
thank you for your help...

Maurice said:
You are correct when you have to convert it to a stringvalue.

Try something like this:

Private Sub Form_Current()
Dim strGUID As String

strGUID = StringFromGUID(lstCompanies)
lstCompanies = strGUID

End Sub

hth
--
Maurice Ausum


rogge said:
when i navigate records on a form the list box should highlight the correct
record.

With an integer as the record id, the following worked just fine...

Private Sub Form_Current()
lstCompanies = [id]
End Sub

but lstCompanies = [idGUID] does not function properly and the row is not
highlighted. I have tried CAST(GUID AS nchar(36)) to use it as a text
string, but still no luck (values are duplicated)

Any ideas to nicely highlight the proper row in the list box for the
appropiate record in the form?

thank you

SQL Server back end
MS Access Project 2003 (ADP)
 
G

Guest

True but I used StringFromGuid frequently in one of my projects a couple of
years ago and that worked as expected..
But as you stated it can be harnessing finding out how to handle this
situation. I bumped into the same situation.
--
Maurice Ausum


rogge said:
Rather than use the actual GUID, i created a calculated field, txtGUID, in
the table for navigation purposes. this cleared many issues... I used the
cast function and named the field txtGUID

it also seems that Access convertes GUDS to strings for the controls; and
this was causing the difficulty....

this is the a from using StringFromGUID:
{guid {E6919771-152B-463D-AC48-FFA22AB088FC}}

one needs create the string like so in Access:
Mid(StringFromGUID([idGUID]), 8, 36)
E6919771-152B-463D-AC48-FFA22AB088FC


rogge said:
when i navigate records on a form the list box should highlight the correct
record.

With an integer as the record id, the following worked just fine...

Private Sub Form_Current()
lstCompanies = [id]
End Sub

but lstCompanies = [idGUID] does not function properly and the row is not
highlighted. I have tried CAST(GUID AS nchar(36)) to use it as a text
string, but still no luck (values are duplicated)

Any ideas to nicely highlight the proper row in the list box for the
appropiate record in the form?

thank you

SQL Server back end
MS Access Project 2003 (ADP)
 

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