HI
I am trying to populate 3 list boxs with data from a table. I have the below code but all i seem to get is the table name or sql statement entered into the listbox. I wonderd if anyone had any ideas? Code follows:
Option Compare Database
Private Sub Form_Load()
Dim daysinmonth As Integer, NextMonth As Integer, EndOfMonth As Integer, currentDate As Date, i As Integer, daysofthemonth As Date
Dim DDay As Integer, DYear As Integer, Dmonth As Integer, DToday As Date
Dim intI As Integer, DDate As Date, todaydate As Date
Dim MySQL As String
NextMonth = DateAdd("m", 1, currentDate)
EndOfMonth = NextMonth - DatePart("d", NextMonth)
daysinmonth = DatePart("d", EndOfMonth)
DDay = Day(Now())
Dmonth = Month(Now())
DYear = Year(Now())
DToday = DateSerial((DYear), (Dmonth), (DDay))
todaydate = DToday - DDay
DDate = todaydate
For i = 1 To 3
DDate = DDate + 1
MySQL = "SELECT tbl_Appt.ApptDate FROM tbl_Appt Where tbl_Appt.ApptDate = " & (DDate) & " ORDER BY tbl_Appt.ApptTime"
Me("list" & CStr(i)).RowSourceType = "value List"
Me("list" & CStr(i)).RowSource = MySQL
Me("list" & CStr(i)).Value = Me("list" & CStr(i)).ItemData(0)
Next
End Sub
many thanks
I am trying to populate 3 list boxs with data from a table. I have the below code but all i seem to get is the table name or sql statement entered into the listbox. I wonderd if anyone had any ideas? Code follows:
Option Compare Database
Private Sub Form_Load()
Dim daysinmonth As Integer, NextMonth As Integer, EndOfMonth As Integer, currentDate As Date, i As Integer, daysofthemonth As Date
Dim DDay As Integer, DYear As Integer, Dmonth As Integer, DToday As Date
Dim intI As Integer, DDate As Date, todaydate As Date
Dim MySQL As String
NextMonth = DateAdd("m", 1, currentDate)
EndOfMonth = NextMonth - DatePart("d", NextMonth)
daysinmonth = DatePart("d", EndOfMonth)
DDay = Day(Now())
Dmonth = Month(Now())
DYear = Year(Now())
DToday = DateSerial((DYear), (Dmonth), (DDay))
todaydate = DToday - DDay
DDate = todaydate
For i = 1 To 3
DDate = DDate + 1
MySQL = "SELECT tbl_Appt.ApptDate FROM tbl_Appt Where tbl_Appt.ApptDate = " & (DDate) & " ORDER BY tbl_Appt.ApptTime"
Me("list" & CStr(i)).RowSourceType = "value List"
Me("list" & CStr(i)).RowSource = MySQL
Me("list" & CStr(i)).Value = Me("list" & CStr(i)).ItemData(0)
Next
End Sub
many thanks