Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List boxes and Spin buttons ??? 1

Status
Not open for further replies.

RemyS

Technical User
Jul 3, 2001
100
GB
Hi All,

I'm still learning Access & VBA, and have come across a piece of functionality I think my users would find useful.
However I'm not sure about how to get it to work...

I have a bound List box in a form which selects the Unique values (dates) from the table
SELECT DISTINCT RF72_HIST.Report_Date FROM RF72_HIST ORDER BY RF72_HIST.Report_Date DESC;.

I have set the default value to be the most recent date
=Max([RF72_HIST]![Report_Date]).

When the form is opened, however, it shows data for all available dates.

I've tried requerying the list box
Private Sub Form_Activate()
DATECHOOSER.Requery
RF72_Subform.Requery
'Form which displays all remaining no-criteria data
End Sub
but I can't set the List Box to exclusively one date until it is clicked on:
Private Sub DATECHOOSER_Click()
PRODUCTCHOOSER.Requery
'Another combo box
RF72_Subform.Requery
End Sub



Can any one help?

The added bit of functionality I wanted to learn, which would prove useful in many other circumstances, was how to use an ActiveX Spinbutton. I don't understand how it works to set a text boxs' value up or down?


All suggestions & advice will be most appreciated,
Rémy
 
Lets say you have text box- txtDate, formatted as mm/dd/yy and you want to update it with an ActiveX Spinbutton named Spin.

Create an event procedure for the Spin object like-

Private Sub Spin_SpinDown()
' Adds 1 day
txtDate = DateAdd("d", -1, txtDate)

End Sub

Private Sub Spin_SpinUp()
' Subtracts 1 day
txtDate = DateAdd("d", 1, txtDate)

End Sub

These will add/subtract 1 day to the date in the text box. Lookup dateadd in Help to find out the syntax for other increments.
Note- You can not see the _SpinUp, _SpinDown events on the property sheet, only in the module window (use the combo boxes on the top of the code window).

Good Luck!
 
Thanks,
The DateAdd function certainly simplified my procedure,

and I now understand a whole lot more about VB
(always wondered about the use of those combo boxes.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top