The following code is what I'm having trouble with. The value that should be returned is "1/27/2004" but I get "12/29/1899." There is only one record in the table. If I substitute the variable reference with the actual table name I get the correct value. However, I need to be able to access the different tables through the variable.
Public Function RecoverForm()
Dim A As Date
Dim User2 As String
DoCmd.Close acForm, "frmRecover", acSaveNo
DoCmd.OpenForm "frmBeginSession"
DoCmd.Restore
User2 = Forms!frmUser!UserID
DoCmd.OpenTable User2, acViewNormal, acReadOnly
DoCmd.GoToRecord , , acFirst
A = DMax("[" & User2 & "]![Date]", User2, "[" & User2 & "]![Begin]"
> 0
Forms![frmbeginsession]![Date] = A
Brian
Public Function RecoverForm()
Dim A As Date
Dim User2 As String
DoCmd.Close acForm, "frmRecover", acSaveNo
DoCmd.OpenForm "frmBeginSession"
DoCmd.Restore
User2 = Forms!frmUser!UserID
DoCmd.OpenTable User2, acViewNormal, acReadOnly
DoCmd.GoToRecord , , acFirst
A = DMax("[" & User2 & "]![Date]", User2, "[" & User2 & "]![Begin]"
Forms![frmbeginsession]![Date] = A
Brian