Spin Button

tnago

Registered User.
Local time
Today, 17:43
Joined
May 2, 2003
Messages
15
I am trying to use spin button to move date up or down in a form field. A new record will have a blank field until a date has been entered into the form. The problem I have is, how to control the spin button so that date go up and down when the button is pressed. As well how to differentiate if the up or down is pressed?

The date format is dd/mm/yyyy. For a new record, when the spin button is pressed, it will start from current day.

Any help in this regard will be greatly appreciated.

Thanks
 
use the spin buttons spinup and spindown event
assuming you want to add 1 day
Private Sub MySpinButton_SpinUp()

if isnull(me.yourdatefield) then
me.yourdatefield=date
else
me.yourdatefield=dateadd("d",1,me.yourdatefield)
end if
End Sub

Private Sub MySpinButton_SpinDown()
if isnull(me.yourdatefield) then
me.yourdatefield=date
else
me.yourdatefield=dateadd("d",-1,me.yourdatefield)
end if
End Sub
 
Thanks for the instruction, but maybe because of my inexperience with VBA and Access I am unable to get it to work. When ever I try to press the spin button I get Compile Error "Method or Data member not found" with (yourdatefield) highlighted. Is it looking for any Dim statement?

This might look very easy to people who are well verse in Access, but I am at a loss. Can someone please help? Also if someone can direct me to a place where I can get further information regarding spin button.
 
sorry for not being more precise.i used the word yourdatefield because i dont know what control name you have used

you have to substitute the word YourDatefield with the
name of the textbox that holds the date you are trying to
manipulate
 

Users who are viewing this thread

Back
Top Bottom