waxdart23
Registered User.
- Local time
- Today, 02:10
- Joined
- Nov 20, 2002
- Messages
- 25
I am using the following to pass two items of data from a form to a Module -
The module is as follows -
When I run this I get the following error "Run-Time error '424'; Object Required". The 'HeadID.Value' is a value from the database and this works fine. However, the StartDate.Value (which seems to be causing the error) is a text box in which the user enters a date to be used as part of the query in the module.
Anyone any ideas how to fix this?
Code:
Call UpdatePerformanceAdd(StewID.Value, StartDate.Value)
The module is as follows -
Code:
Public Sub UpdatePerformanceAdd(lStew_Num As Long, lStartDate As Date)
Dim Dbs As Database: Set Dbs = CurrentDb
Dim rstPerf As Recordset
Dim rstFuture As Recordset
Dim strSQL As String
strSQL = "SELECT Performances.ID, Performances.Perf_Date, Performances.Duration FROM Performances "
strSQL = strSQL & "WHERE (((Performances.Perf_Date)>=" & lStartDate & "));"
Set rstPerf = Dbs.OpenRecordset(strSQL)
Set rstFuture = Dbs.OpenRecordset("StewardAvailability", dbOpenDynaset)
With rstFuture
rstPerf.MoveLast: rstPerf.MoveFirst
While Not rstPerf.EOF
'add new record to availability table
.AddNew
!Stewards_ID = lStew_Num 'copy performance id #
!Perf_ID = rstPerf!ID 'copy staff ID number
!Availability = False 'set availability to false
!Memo = " " 'Leave memo field blank
!Duty_length = rstPerf!Duration 'copy duty duration
.Update 'update recordset
rstPerf.MoveNext 'move to next contracted employee
Wend
End With
rstFuture.Close
rstPerf.Close
strSQL = ""
Set Dbs = Nothing
End Sub
When I run this I get the following error "Run-Time error '424'; Object Required". The 'HeadID.Value' is a value from the database and this works fine. However, the StartDate.Value (which seems to be causing the error) is a text box in which the user enters a date to be used as part of the query in the module.
Anyone any ideas how to fix this?