Addressing listbox

C

Clinton

Hallo,

Got a suggestion for changing adressing a listbox based on a text box.

But i still have problems to get it to work.

Based on ID field as number: works fine...
Me.RecordsetClone.FindFirst "[OGnumberID] = " & Me![OGList]
Me.Bookmark = Me.RecordsetClone.Bookmark
Me.[OGList].Value = Me.[OGnumberID].Value


Based on ID field as text: doesnt work...
Me.RecordsetClone.FindFirst "[OGtextID] = " & Chr$(34) & Me![OGList] &
Chr$(34)
Me.Bookmark = Me.RecordsetClone.Bookmark
Chr$ (34) & Me![OGList] & Chr$(34) & Value = Me.[OGtextID].Value

Tried a lot of combinations but can't figure out what to change in the above
ID field as text code...



Regards,
Brian
 
G

Graham Mandeno

Hi Brian

This line:
Chr$ (34) & Me![OGList] & Chr$(34) & Value = Me.[OGtextID].Value
should be similar to the one above - that is:
Me.[OGList].Value = Me.[OGtextID].Value

However, both of them are unnecessary, because the listbox value will
already be the same as the ID value - you only just used it to do the
lookup!

If you want to ensure that the listbox value changes as you navigate from
one record to another, put the line of code in your Form_Current procedure.

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Clinton said:
Hallo,

Got a suggestion for changing adressing a listbox based on a text box.

But i still have problems to get it to work.

Based on ID field as number: works fine...
Me.RecordsetClone.FindFirst "[OGnumberID] = " & Me![OGList]
Me.Bookmark = Me.RecordsetClone.Bookmark
Me.[OGList].Value = Me.[OGnumberID].Value


Based on ID field as text: doesnt work...
Me.RecordsetClone.FindFirst "[OGtextID] = " & Chr$(34) & Me![OGList] &
Chr$(34)
Me.Bookmark = Me.RecordsetClone.Bookmark
Chr$ (34) & Me![OGList] & Chr$(34) & Value = Me.[OGtextID].Value

Tried a lot of combinations but can't figure out what to change in the above
ID field as text code...



Regards,
Brian
 
B

Brian

Hallo,

Thanx for the reply.

Based on your suggestion i tried various combinations but can't get it to
work:

Me.RecordsetClone.FindFirst Chr$(34) & Me![OGtextID] & Chr$(34) = Chr$(34) &
Me![OGList] & Chr$(34)
Me.Bookmark = Me.RecordsetClone.Bookmark
Chr$ (34) & Me![OGList] & Chr$(34) & Value = Chr$(34) & Me![OGtextID] &
Chr$(34) & Value

The last line also in form_current

Something wrong with the code?

Regards,
Brian





Graham Mandeno said:
Hi Brian

This line:
Chr$ (34) & Me![OGList] & Chr$(34) & Value = Me.[OGtextID].Value
should be similar to the one above - that is:
Me.[OGList].Value = Me.[OGtextID].Value

However, both of them are unnecessary, because the listbox value will
already be the same as the ID value - you only just used it to do the
lookup!

If you want to ensure that the listbox value changes as you navigate from
one record to another, put the line of code in your Form_Current procedure.

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Clinton said:
Hallo,

Got a suggestion for changing adressing a listbox based on a text box.

But i still have problems to get it to work.

Based on ID field as number: works fine...
Me.RecordsetClone.FindFirst "[OGnumberID] = " & Me![OGList]
Me.Bookmark = Me.RecordsetClone.Bookmark
Me.[OGList].Value = Me.[OGnumberID].Value


Based on ID field as text: doesnt work...
Me.RecordsetClone.FindFirst "[OGtextID] = " & Chr$(34) & Me![OGList] &
Chr$(34)
Me.Bookmark = Me.RecordsetClone.Bookmark
Chr$ (34) & Me![OGList] & Chr$(34) & Value = Me.[OGtextID].Value

Tried a lot of combinations but can't figure out what to change in the above
ID field as text code...



Regards,
Brian
 
G

Graham Mandeno

Hi Brian

You only needed to change one line!

This is all fine:

Me.RecordsetClone.FindFirst "[OGtextID] = " & Chr$(34) & Me![OGList] &
Chr$(34)
Me.Bookmark = Me.RecordsetClone.Bookmark

This line is wrong:

Chr$ (34) & Me![OGList] & Chr$(34) & Value = Me.[OGtextID].Value

It should be:

Me.[OGList].Value = Me.[OGtextID].Value

or even just:

Me.[OGList] = Me.[OGtextID]

....and you should put in in Form_Current

I hope that's clear now :)

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Brian said:
Hallo,

Thanx for the reply.

Based on your suggestion i tried various combinations but can't get it to
work:

Me.RecordsetClone.FindFirst Chr$(34) & Me![OGtextID] & Chr$(34) = Chr$(34) &
Me![OGList] & Chr$(34)
Me.Bookmark = Me.RecordsetClone.Bookmark
Chr$ (34) & Me![OGList] & Chr$(34) & Value = Chr$(34) & Me![OGtextID] &
Chr$(34) & Value

The last line also in form_current

Something wrong with the code?

Regards,
Brian





Graham Mandeno said:
Hi Brian

This line:
Chr$ (34) & Me![OGList] & Chr$(34) & Value = Me.[OGtextID].Value
should be similar to the one above - that is:
Me.[OGList].Value = Me.[OGtextID].Value

However, both of them are unnecessary, because the listbox value will
already be the same as the ID value - you only just used it to do the
lookup!

If you want to ensure that the listbox value changes as you navigate from
one record to another, put the line of code in your Form_Current procedure.

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Clinton said:
Hallo,

Got a suggestion for changing adressing a listbox based on a text box.

But i still have problems to get it to work.

Based on ID field as number: works fine...
Me.RecordsetClone.FindFirst "[OGnumberID] = " & Me![OGList]
Me.Bookmark = Me.RecordsetClone.Bookmark
Me.[OGList].Value = Me.[OGnumberID].Value


Based on ID field as text: doesnt work...
Me.RecordsetClone.FindFirst "[OGtextID] = " & Chr$(34) & Me![OGList] &
Chr$(34)
Me.Bookmark = Me.RecordsetClone.Bookmark
Chr$ (34) & Me![OGList] & Chr$(34) & Value = Me.[OGtextID].Value

Tried a lot of combinations but can't figure out what to change in the above
ID field as text code...



Regards,
Brian
 

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

Similar Threads


Top