Full Version: One calendar multiple date fields
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
tjcinnamon
I have calender that appears after you click on the date field. I made it more universal so I didn't have a bunch of invisible calender controls all over my form. I had it working until I tried to change the default date to of the calender by passing a date through in my UDF (OpenCalendar). I keep getting the error "Syntax Error", why would I get this on adding a second parameter??

Here is the code:
CODE

'In forms module

Private Sub DateReceived_Click()
    OpenCalendar ("DR", Me.DateReceived)
End Sub

Private Sub EventDate_Click()
    OpenCalendar ("ED", Me.EventDate)
End Sub

'In it's own module
Global st as String
Public Function OpenCalendar(start As String, d As Date)
  
Forms!EventEntry!Calendar0.Visible = True
    If IsNull(d) Then
        Forms!EventEntry!Calander0.Value = Date
    Else
        Forms!EventEntry!Calander0.Value = d
    End If
    st = start

End Function
fkegley
I think the problem is that the parameter d which is of type Date cannot accept a Null value. Change its type to Variant.
tjcinnamon
I changed its type to a variant.

I still get the syntax error when I try to compile at this line: OpenCalendar ("DR", Me.DateReceived). When I type in the same line again to make sure the syntax is correct I get an "expected: =" error.
tjcinnamon
I dimed a temp variable to get the value of me.daterecieved just in case it had problems passing a me.value. I still got an error it compiles with one argument, but not two. Which leads me to believe that the problem is in the function (but it doesn't make sense, I should be able to pass 2 arguments of different type).
fkegley
Yes, I agree with that. Could it be some kind of corruption? Try this, copy the code of the function. Add a new module, then paste the code into that one.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.