Doing stuff by Date

  • Thread starter Thread starter Regan via AccessMonster.com
  • Start date Start date
R

Regan via AccessMonster.com

hi. In my startup form i have a textbox withthe control source =Date()
[text27]. I have another textbox(unbound) [text29] where i want to put
another date. What i want to do is when [text27] = [text29] then 'do some
stuff' [text29] = [text27]. How do i put the a value in [text29] and keep it
there?. i put in 21/07/06 in the default value and when i reload the form it
comes up 30/12/1889. i haven't done programming but this is what i think i
want to do

Private Sub Form_Open(Cancel As Integer)

Dim DNW As Date
Dim DTD As Date
Dim stdocname As String

DTD = Text27.Value
DNW = Text29.Value
stdocname = "WageBal"

If DNW = DTD Then
Text29.Value = DTD + 7 ' and date stay there until it is reached again.
its not satying there now
DoCmd.OpenForm stdocname
'do some stuff and close form
Else
Exit Sub
End If

End Sub

i hope this makes sense
thanks
 
Just a quick glance at your post finds an issue with your default " i put in
21/07/06 in the default value "
Try set the default to #21/07/06#

I'm not sure how this works on your side of whatever pond.
 
yep put them in. cheers, but how do i put it in the code so that DTD + 7
comes our #21/07/06# instead of 21/07/06. How do i put the hashes in. th

Dim DNW As Date
Dim DTD As Date
Dim stdocname As String

DTD = Text27.Value
DNW = Text29.Value
stdocname = "WageBal"

If DNW = DTD Then
Text29.DefaultValue = DTD + 7 'i want hashes around this bit

DoCmd.OpenForm stdocname

Else
Exit Sub
End If

Thanks for help
 
Do yourself a favor and give your text boxes decent names. Your code is much
more maintainable. I also use "Me." in front of all form control names to
avoid confusion.

Me.Text29.DefaultValue = "#" & DateAdd("d",7,DTD) & "#" 'i want hashes
around this bit
 
Back
Top