VBA code with Date() function not working in runtime mode

phoust

New member
Local time
Today, 15:45
Joined
Aug 20, 2024
Messages
10
I have an invoice form with a combo box to update the status of the invoice. The following code is triggered After Update.

If Me.StatusGroup = "QUOTE" Then
Me.QuoteRequestDate.Visible = True
Me.QuoteRequestDate.Value = Date
Else
Me.QuoteRequestDate.Value = ""
Me.QuoteRequestDate.Visible = False
End If

It works fine in the accdb file, but when I compile to accde and accdr files it will not run. If I comment out the DATE lines and run without the DATE function it works in runtime.

I want to update the date with the current date when the status changes. Is there another way to do this?
 
Date should work in runtime. What was the error message in runtime? Perhaps the problem is somewhere else.
 
There's no error message, I just can't open the form this appears on.
 
If I comment out the DATE lines
I only see one line where the date function is used.

Simple test to see if there is a problem with Date:
Msgbox "Current date: " & Date

Is QuoteRequestDate an AccessField or a Control/TextBox?
If you change the data source dynamically, you could try Me!QuoteRequestDate instead of Me.QuoteRequestDate.

BTW:
Me.QuoteRequestDate.Value = ""
Is QuoteRequestDate a text data type because you assign “”.
Me.QuoteRequestDate.Value = Null
 
Me.QuoteRequestDate.Value = ""
I would expect this to generate an error if the control is bound to a date field and Me.StatusGroup <>”QUOTE" . If you are not getting an error the implication is you have turned warnings off
 
The change to Me!QuoteRequestDate.Value worked. Thank you!
 

Users who are viewing this thread

Back
Top Bottom