Hi
Hopefully someone can help me.
I am working on a database that is going to be used to store and show appointments at a friends hairdressing salon.
I have an appointments table that holds the following details:
ID this is a concatenation of Date, time, stylist number and customer name
CustName Customer Name
StylistNo Stylists name
AppDate Appointment Date
AppDay Appointment Day
AppStartTime Time of Appointment
ServiceCode Code number of Service required
AppDuration Appointment Duration in Minutes
Price Cost of Service
Textbox Name of the corresponding textbox on the DailyDiary form
I have a form called DailyDiary and on this there are a textbox call txtDate that is a date selection then I have textboxes that relate to half hourly appointments for each stylist. these are named as follows:
For stylist 1 an appointment at 08.00 would be called txt10800 where 10800 is stylist 1 at 08.00
For stylist 3 an appointment at 11.00 would be called txt31100 where 31100 is stylist 3 at 11.00
etc
When a date is entered into txtDate I have an afterupdate event that should fill all the textboxes from a query called PopulateDailyDiary.
PopulateDailyDiary has the following fields:
TextBox the name of the corresponding textbox on the DailyDiary form
AppDate the date of the appointment - filtered to agree to the date selected in txtDate on the DailyDiary form
TextFill the data that I want to fill the corresponding textbox on the form.
The code I am using is as follows but I keep getting a 3061 error and then an out of range error
Code:
Private Sub txtDate_AfterUpdate()
Dim i As Integer
Dim arrTXT As Variant
Dim rs As Recordset
Dim db As Database
i = 0
arrTXT = Array(Me.txt10800, Me.txt10830, Me.txt10900, Me.txt10930, Me.txt11000, Me.txt11030, Me.txt11100, Me.txt11130)
Set db = CurrentDb()
Set rs = db.OpenRecordset("PopulateDailyDiary", dbOpenDynaset)
strSQL = "SELECT textFill FROM PopulateDailyDiary WHERE [Queries]![PopulateDailyDiary]![AppDate] = [forms]![DailyDiary]![txtDate];"
With rs
If .BOF Or .EOF Then
.Close
Else
Do Until .EOF
arrTXT(i).SetFocus
Me.ActiveControl = .Fields("textfill")
i = i + 1
.MoveNext
Loop
End If
.Close
End With
Set rs = Nothing
Set db = Nothing
Me.txtDay = Format(txtDate, "dddd")
End Sub
Can someone help me with the code to see what I have done wrong
Thanks
Rich