Default setting in a list box

  • Thread starter trekgoes2malaysia
  • Start date
T

trekgoes2malaysia

I'm trying to highlight a date in a list box based on a date in
another form . I want the user to click a control on one form that
opens another form which contains a long listbox of dates. Because the
list of dates is very long, I am trying to save the user time by
avoiding the need to scroll down to find the date they want each time
they open the form. Rather, the procedure should automatically scroll
through the listbox to the same date (id) that is on the parent
form. How can I do this in VBA?

Below is my attempt that didn't work.
********************************************************************************************
Private Sub PickNewDate_Click()
On Error GoTo Err_PickNewDate_Click


Dim stFormName As String

stFormName = "frmdateselect"

DoCmd.OpenForm stFormName

Forms!frmdateselect!ListPickDate.DefaultValue = Forms!datelog!
dateid.Value



Exit_PickNewDate_Click:
Exit Sub

Err_PickNewDate_Click:
MsgBox Err.Description
Resume Exit_PickNewDate_Click

End Sub
********************************************************************************************
 
S

Stuart McCall

I'm trying to highlight a date in a list box based on a date in
another form . I want the user to click a control on one form that
opens another form which contains a long listbox of dates. Because the
list of dates is very long, I am trying to save the user time by
avoiding the need to scroll down to find the date they want each time
they open the form. Rather, the procedure should automatically scroll
through the listbox to the same date (id) that is on the parent
form. How can I do this in VBA?

Below is my attempt that didn't work.
********************************************************************************************
Private Sub PickNewDate_Click()
On Error GoTo Err_PickNewDate_Click


Dim stFormName As String

stFormName = "frmdateselect"

DoCmd.OpenForm stFormName

Forms!frmdateselect!ListPickDate.DefaultValue = Forms!datelog!
dateid.Value



Exit_PickNewDate_Click:
Exit Sub

Err_PickNewDate_Click:
MsgBox Err.Description
Resume Exit_PickNewDate_Click

End Sub
********************************************************************************************

Simply remove 'Default', ie:

Forms!frmdateselect!ListPickDate.Value = Forms!datelog!dateid.Value
 
B

boblarson

Stuart's answer is on the right track, but I have to remind you that you need
to set the value found in the BOUND column which is not necessarily the value
that is displayed.
--
Bob Larson
Access World Forums Super Moderator
Utter Access VIP
Tutorials at http://www.btabdevelopment.com
__________________________________
If my post was helpful to you, please rate the post.
 
T

trekgoes2malaysia

Simply remove 'Default', ie:

Forms!frmdateselect!ListPickDate.Value = Forms!datelog!dateid.Value- Hide quoted text -

- Show quoted text -

Ok Thanks will try. Really appreciate your effort to help.
Patrick
 

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