DAO.Recordset

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
 
V

Van T. Dinh

If you have Access on the PC, you will have DAO Library (version 3.6 for A2K
or later). All you need to do is to include the DAO Library in the
References.

I am not sure the person who advised you about the DAO Recordset knows what
he/she is talking about.
 
D

Dirk Goldgar

Lindsey M said:
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'm not sure what you mean by "the recordset access is not included in
the work installation". What error message do you actually get? Did
you just copy the code from your home PC to the database on the work PC,
or did you copy the whole database? If the former is the case, it may
be that the database at work just doesn't have a reference set to the
DAO object library. If that's not it, I suppose the reference to DAO
could be broken, but aside from that I'm not sure what could be the
problem. What version of Access are you using at home? At work?

In the VB Editor environment, click Tools -> References... and look for
any references marked as MISSING. Are there any? Also, make sure
there's a reference set to the Microsoft DAO 3.6 Object Library (if
you're using Access 2000 or later at work).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top