Editting table records from form

benbenson

New member
Local time
Today, 20:15
Joined
Jul 17, 2002
Messages
7
Im trying to create a customer details form that will take two user inputted dates (txtbookingstart and txtbookingend) and a room no. Then on the click event, edit the customerid field in the appropriate records in a different table "booking". Here is my code so far:

Private Sub Command22_Click()
Dim dbs As Database, rst As Recordset
Dim startdate As Date

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("Booking", dbOpenDynaset)
startdate = txtStartbooking.Text
Do Until startdate = txtEndBooking.Text
rst.FindFirst !Date = startdate And !roomno = txtRoomNo.Text

With rst
.Edit
!CustomerID = customerdetails.CustomerID
.Update
startdate = startdate + 1
End With
Loop

End Sub

It doesnt seem to like the fields in the booking table, i.e. !date. Also, Im not sure how to reference the customerid field, as it is the field that links the two tables.
Any Help MUCH APPRECIATED!!
 
Date is a reserved word in access, you shouldn't use it for a field name, change it before going any further
 

Users who are viewing this thread

Back
Top Bottom