Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting form data in table

Status
Not open for further replies.
Jul 17, 2002
22
0
0
US
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



 
Make sure you have Microsoft DAO 3.6 Objects Library checked in references (Tools). If that doesn't exist in the list, use the latest DAO Objects Lib.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top