Unable to Add Records

  • Thread starter Thread starter John C
  • Start date Start date
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
 
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.
 
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


.
 
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


.
 
Back
Top