N
niclive
Helo.I'm having trouble with this function.I created a table with four
fields dtinitial, dtexpire, regkey and ID as primary key.I want to
update the table if the user enters a correct regkey.However I don't
want to use sql update.I want it to be done automatically without user
interaction.When I try the function I get an error saying Object
Required.This comes after the welcome msgbox displays.
What could be the problem?Please help.
Public Function expire()
On Error GoTo Err_trap
Dim dtexpire As Date
Dim dtInitial As Date
Dim regkey1 As String
dtexpire = DLookup("[dtexpire]", "[Source]", "[dtexpire]")
dtInitial = DLookup("[dtInitial]", "[Source]", "[dtInitial]")
regkey = DLookup("[regkey]", "[Source]", "[regkey]")
regkey1 = InputBox("Please enter your Section Code:","Section Code
Required")
If dtexpire < dtInitial Then
If regkey1 = regkey Then
MsgBox " WELCOME !", vbInformation, "Access Granted"
Source.dtexpire = Source.dtexpire + 30
Source.regkey = Source.regkey + 1001
Else
MsgBox "You provided wrong information!", vbInformation, "Access
Denied"
DoCmd.Quit
End If
End If
Exit_function:
Exit Function
Err_trap:
MsgBox Err.Description
Resume Exit_function
End Function
fields dtinitial, dtexpire, regkey and ID as primary key.I want to
update the table if the user enters a correct regkey.However I don't
want to use sql update.I want it to be done automatically without user
interaction.When I try the function I get an error saying Object
Required.This comes after the welcome msgbox displays.
What could be the problem?Please help.
Public Function expire()
On Error GoTo Err_trap
Dim dtexpire As Date
Dim dtInitial As Date
Dim regkey1 As String
dtexpire = DLookup("[dtexpire]", "[Source]", "[dtexpire]")
dtInitial = DLookup("[dtInitial]", "[Source]", "[dtInitial]")
regkey = DLookup("[regkey]", "[Source]", "[regkey]")
regkey1 = InputBox("Please enter your Section Code:","Section Code
Required")
If dtexpire < dtInitial Then
If regkey1 = regkey Then
MsgBox " WELCOME !", vbInformation, "Access Granted"
Source.dtexpire = Source.dtexpire + 30
Source.regkey = Source.regkey + 1001
Else
MsgBox "You provided wrong information!", vbInformation, "Access
Denied"
DoCmd.Quit
End If
End If
Exit_function:
Exit Function
Err_trap:
MsgBox Err.Description
Resume Exit_function
End Function