C
castle
Im using access 2003 Vb code
I cant get the times (lst_StartTime and lst_EndTime) to save to the
database tables. Timetable no. and client no. do save, i've left out the
dayNo as it says needs related data so nulling it for now.
Option Compare Database
Option Explicit
Dim cn As ADODB.Connection
Dim rs_Timetable As ADODB.Recordset
Dim rs_Client As ADODB.Recordset
Dim rs_Cleaning As ADODB.Recordset
Private Sub btn_Add_Click()
With rs_Timetable
.AddNew ' Blank Record
!TimeTableNo = lbl_TimeTableNo.Caption
!ClientNo = lst_Client '.Column(1)
'!DayNo = Lst_Day.Column(1)
!DayNo = Null
!StartTime = Lst_StartTime.Value
!EndTime = lst_EndTime
!StaffNo = lst_Staff '.Column(1)
.Update
End With
End Sub
Private Sub cmd_exit_Click()
DoCmd.Close
End Sub
Private Sub Form_Load()
DoCmd.Maximize
Lbl_date.Caption = Date
Set cn = CurrentProject.Connection
Set rs_Timetable = New ADODB.Recordset
rs_Timetable.Open "Timetable", cn, adOpenDynamic, adLockOptimistic,
adCmdTableDirect
rs_Timetable.Index = "PrimaryKey"
Set rs_Client = New ADODB.Recordset
rs_Client.Open "Client", cn, adOpenDynamic, adLockOptimistic, adCmdTableDirect
rs_Client.Index = "PrimaryKey"
Set rs_Cleaning = New ADODB.Recordset
rs_Cleaning.Open "CleaningDays", cn, adOpenDynamic, adLockOptimistic,
adCmdTableDirect
rs_Cleaning.Index = "PrimaryKey"
With rs_Timetable
If .EOF = True Then
lbl_TimeTableNo.Caption = 1000
Else
.MoveLast
lbl_TimeTableNo.Caption = !TimeTableNo + 1
End If
End With
Detail.Visible = False
lst_Client.SetFocus
End Sub
Private Sub Form_Timer()
lbl_time.Caption = Format(Now, "hh:mm:ss")
End Sub
Private Sub lst_Client_AfterUpdate()
Detail.Visible = True
rs_Client.Seek lst_Client, adSeekFirstEQ
rs_Cleaning.Seek rs_Client!ChargeNo, adSeekFirstEQ
lbl_Hours.Caption = rs_Cleaning!Noofhours
lbl_StartDate.Caption = rs_Client!StartDate
If rs_Cleaning!duration = "F" Then
lbl_Duration.Caption = "Fortnightly"
Else
lbl_Duration.Caption = "Monthly"
End If
Lst_Day.SetFocus
End Sub
Tried this but it don't work
!StartTime = format(lst_Start.value,"dd-mmm-yyyy hh:mms")
I cant get the times (lst_StartTime and lst_EndTime) to save to the
database tables. Timetable no. and client no. do save, i've left out the
dayNo as it says needs related data so nulling it for now.
Option Compare Database
Option Explicit
Dim cn As ADODB.Connection
Dim rs_Timetable As ADODB.Recordset
Dim rs_Client As ADODB.Recordset
Dim rs_Cleaning As ADODB.Recordset
Private Sub btn_Add_Click()
With rs_Timetable
.AddNew ' Blank Record
!TimeTableNo = lbl_TimeTableNo.Caption
!ClientNo = lst_Client '.Column(1)
'!DayNo = Lst_Day.Column(1)
!DayNo = Null
!StartTime = Lst_StartTime.Value
!EndTime = lst_EndTime
!StaffNo = lst_Staff '.Column(1)
.Update
End With
End Sub
Private Sub cmd_exit_Click()
DoCmd.Close
End Sub
Private Sub Form_Load()
DoCmd.Maximize
Lbl_date.Caption = Date
Set cn = CurrentProject.Connection
Set rs_Timetable = New ADODB.Recordset
rs_Timetable.Open "Timetable", cn, adOpenDynamic, adLockOptimistic,
adCmdTableDirect
rs_Timetable.Index = "PrimaryKey"
Set rs_Client = New ADODB.Recordset
rs_Client.Open "Client", cn, adOpenDynamic, adLockOptimistic, adCmdTableDirect
rs_Client.Index = "PrimaryKey"
Set rs_Cleaning = New ADODB.Recordset
rs_Cleaning.Open "CleaningDays", cn, adOpenDynamic, adLockOptimistic,
adCmdTableDirect
rs_Cleaning.Index = "PrimaryKey"
With rs_Timetable
If .EOF = True Then
lbl_TimeTableNo.Caption = 1000
Else
.MoveLast
lbl_TimeTableNo.Caption = !TimeTableNo + 1
End If
End With
Detail.Visible = False
lst_Client.SetFocus
End Sub
Private Sub Form_Timer()
lbl_time.Caption = Format(Now, "hh:mm:ss")
End Sub
Private Sub lst_Client_AfterUpdate()
Detail.Visible = True
rs_Client.Seek lst_Client, adSeekFirstEQ
rs_Cleaning.Seek rs_Client!ChargeNo, adSeekFirstEQ
lbl_Hours.Caption = rs_Cleaning!Noofhours
lbl_StartDate.Caption = rs_Client!StartDate
If rs_Cleaning!duration = "F" Then
lbl_Duration.Caption = "Fortnightly"
Else
lbl_Duration.Caption = "Monthly"
End If
Lst_Day.SetFocus
End Sub
Tried this but it don't work
!StartTime = format(lst_Start.value,"dd-mmm-yyyy hh:mms")