L
Lindsey M
Hi
I have a DB that I have used the following code:
Private Sub cmdOK_Click()
Dim rs As DAO.Recordset
Dim db As DAO.Database
Dim strSQL As String
Dim sUserID As String
Dim sRoomID As String
Dim dDate As Date
Dim StartTime As String
Dim EndTime As String
On Error GoTo cmdOK_Err
strSQL = "Select * from tblSchedule"
sUserID = Me.txtUser
sRoomID = Me.cmbRoomReq
dDate = Me.txtDate
StartTime = Me.lstStart
EndTime = Me.lstEnd
Me.lstConflict.Requery
If Me.lstConflict.ListCount > 0 Then
MsgBox "Unfortunately, this room is unavailable for the time you
have requested - Please try again", vbOKOnly, "Room Not Available"
Else
Set db = CurrentDb
Set rs = db.OpenRecordSet(strSQL, dbOpenDynaset, dbSeeChanges)
With rs
.AddNew
!UserID = sUserID
!RoomID = sRoomID
!Date = dDate
!StartTime = StartTime
!EndTime = EndTime
.Update
End With
MsgBox "Booking confirmed"
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End If
Exit Sub
cmdOK_Err:
MsgBox "Please check details and try again", vbOKOnly, "Error!"
End Sub
Which works great, however, I developed this (with a lot of help!) on my own
PC and when I have taken it into work, I have been informed that the
recordset access is not included in the work installation and that I will
need to use SQL to add the records to the table.
Has anyone got any ideas on where I could find info on how to do this? Any
help would be greatly appreciated.
Cheers
Lindsey M
I have a DB that I have used the following code:
Private Sub cmdOK_Click()
Dim rs As DAO.Recordset
Dim db As DAO.Database
Dim strSQL As String
Dim sUserID As String
Dim sRoomID As String
Dim dDate As Date
Dim StartTime As String
Dim EndTime As String
On Error GoTo cmdOK_Err
strSQL = "Select * from tblSchedule"
sUserID = Me.txtUser
sRoomID = Me.cmbRoomReq
dDate = Me.txtDate
StartTime = Me.lstStart
EndTime = Me.lstEnd
Me.lstConflict.Requery
If Me.lstConflict.ListCount > 0 Then
MsgBox "Unfortunately, this room is unavailable for the time you
have requested - Please try again", vbOKOnly, "Room Not Available"
Else
Set db = CurrentDb
Set rs = db.OpenRecordSet(strSQL, dbOpenDynaset, dbSeeChanges)
With rs
.AddNew
!UserID = sUserID
!RoomID = sRoomID
!Date = dDate
!StartTime = StartTime
!EndTime = EndTime
.Update
End With
MsgBox "Booking confirmed"
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End If
Exit Sub
cmdOK_Err:
MsgBox "Please check details and try again", vbOKOnly, "Error!"
End Sub
Which works great, however, I developed this (with a lot of help!) on my own
PC and when I have taken it into work, I have been informed that the
recordset access is not included in the work installation and that I will
need to use SQL to add the records to the table.
Has anyone got any ideas on where I could find info on how to do this? Any
help would be greatly appreciated.
Cheers
Lindsey M