soontobefour
MIS
I am new to VBA and are trying to insert data entered by the user on a form to a table. This is the code I have so far, but the Dimming and setting of CurrentDB does not work. What could be the problem?Dim tbl As TableDef
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("Reservation", dbOpenTable)
With rst
If .RecordCount = 0 Then
.AddNew
.Move 0
'.LastModified
' Set the ID property for this new cat.
End If
!Room = Roomtxt
!Date = datetxt
!start_Time = starttimetxt
!end_time = Endtimetxt
!Requestor = requestortxt
!Phone = phonetxt
!am_pm = am_pmtxt
.Update
End With
Save = True
ExitHere:
If Not rst Is Nothing Then rst.Close
Set rst = Nothing
Set db = Nothing
Set tbl = Nothing
Exit Sub
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("Reservation", dbOpenTable)
With rst
If .RecordCount = 0 Then
.AddNew
.Move 0
'.LastModified
' Set the ID property for this new cat.
End If
!Room = Roomtxt
!Date = datetxt
!start_Time = starttimetxt
!end_time = Endtimetxt
!Requestor = requestortxt
!Phone = phonetxt
!am_pm = am_pmtxt
.Update
End With
Save = True
ExitHere:
If Not rst Is Nothing Then rst.Close
Set rst = Nothing
Set db = Nothing
Set tbl = Nothing
Exit Sub