Unable to Add Records

J

John C

I have just converted my databases to Access XP.
1 DB is used for data storage, the other (which will be
converted to MDE later) is the user interface program.

The code below worked in Access 97', but no longer places
the record into the database in Access XP.

Sub MyAddRecord()

Dim dbLog3 As Database, rcdEntry3 As Recordset
Set dbLog3 = CurrentDb()
Set rcdEntry3 = dbLog3.OpenRecordset("tblLogbook_U3")
rcdEntry3.AddNew

With rcdEntry3
![EntryDate] = Me.txtDate
![EntryTime] = Me.txtTime
![Shift] = Me.Shift
![Entry] = Me.txtEntry
![System] = Me.SystemList
End With

rcdEntry3.Update

End Sub
 
J

Jeff Conrad

Just a guess here.
Access 2000 and 2002 do not set a reference to the DAO object library by default.

1. Add a reference (in VB Editor, click Tools -> References...) to
Microsoft DAO 3.6 Object Library.

2. Change your code to this:
(Notice we explicitly tell Access that we are using DAO code)

Sub MyAddRecord()

Dim dbLog3 As DAO.Database, rcdEntry3 As DAO.Recordset
Set dbLog3 = CurrentDb()
Set rcdEntry3 = dbLog3.OpenRecordset("tblLogbook_U3")
rcdEntry3.AddNew

With rcdEntry3
![EntryDate] = Me.txtDate
![EntryTime] = Me.txtTime
![Shift] = Me.Shift
![Entry] = Me.txtEntry
![System] = Me.SystemList
End With

rcdEntry3.Update

End Sub

3. Compile the code, and then test.
 
J

John C.

This did not resolve the problem...any thing else?

-----Original Message-----
Just a guess here.
Access 2000 and 2002 do not set a reference to the DAO object library by default.

1. Add a reference (in VB Editor, click Tools -> References...) to
Microsoft DAO 3.6 Object Library.

2. Change your code to this:
(Notice we explicitly tell Access that we are using DAO code)

Sub MyAddRecord()

Dim dbLog3 As DAO.Database, rcdEntry3 As DAO.Recordset
Set dbLog3 = CurrentDb()
Set rcdEntry3 = dbLog3.OpenRecordset("tblLogbook_U3")
rcdEntry3.AddNew

With rcdEntry3
![EntryDate] = Me.txtDate
![EntryTime] = Me.txtTime
![Shift] = Me.Shift
![Entry] = Me.txtEntry
![System] = Me.SystemList
End With

rcdEntry3.Update

End Sub

3. Compile the code, and then test.

--
Jeff Conrad
Access Junkie
Bend, Oregon

I have just converted my databases to Access XP.
1 DB is used for data storage, the other (which will be
converted to MDE later) is the user interface program.

The code below worked in Access 97', but no longer places
the record into the database in Access XP.

Sub MyAddRecord()

Dim dbLog3 As Database, rcdEntry3 As Recordset
Set dbLog3 = CurrentDb()
Set rcdEntry3 = dbLog3.OpenRecordset("tblLogbook_U3")
rcdEntry3.AddNew

With rcdEntry3
![EntryDate] = Me.txtDate
![EntryTime] = Me.txtTime
![Shift] = Me.Shift
![Entry] = Me.txtEntry
![System] = Me.SystemList
End With

rcdEntry3.Update

End Sub


.
 
J

Jeff Conrad

Strange, works just perfect in my test.

Do you get any error messages at all?
Is the form open when you run this code?
How are you launching the procedure?
Compile your database and see if any problems are found and then compact.
Do you have any Timer events running that could interfere?
Try stepping through the code and see if anything looks weird.

--
Jeff Conrad
Access Junkie
Bend, Oregon

John C. said:
This did not resolve the problem...any thing else?

-----Original Message-----
Just a guess here.
Access 2000 and 2002 do not set a reference to the DAO object library by default.

1. Add a reference (in VB Editor, click Tools -> References...) to
Microsoft DAO 3.6 Object Library.

2. Change your code to this:
(Notice we explicitly tell Access that we are using DAO code)

Sub MyAddRecord()

Dim dbLog3 As DAO.Database, rcdEntry3 As DAO.Recordset
Set dbLog3 = CurrentDb()
Set rcdEntry3 = dbLog3.OpenRecordset("tblLogbook_U3")
rcdEntry3.AddNew

With rcdEntry3
![EntryDate] = Me.txtDate
![EntryTime] = Me.txtTime
![Shift] = Me.Shift
![Entry] = Me.txtEntry
![System] = Me.SystemList
End With

rcdEntry3.Update

End Sub

3. Compile the code, and then test.

--
Jeff Conrad
Access Junkie
Bend, Oregon

I have just converted my databases to Access XP.
1 DB is used for data storage, the other (which will be
converted to MDE later) is the user interface program.

The code below worked in Access 97', but no longer places
the record into the database in Access XP.

Sub MyAddRecord()

Dim dbLog3 As Database, rcdEntry3 As Recordset
Set dbLog3 = CurrentDb()
Set rcdEntry3 = dbLog3.OpenRecordset("tblLogbook_U3")
rcdEntry3.AddNew

With rcdEntry3
![EntryDate] = Me.txtDate
![EntryTime] = Me.txtTime
![Shift] = Me.Shift
![Entry] = Me.txtEntry
![System] = Me.SystemList
End With

rcdEntry3.Update

End Sub


.
 

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