trouble adding records to table

K

Keeage

I'm making a database that inputs large text files and stores the data.
I can connect to the db, display it's contents and navigate, but when
I try to add records, everything appears to function properly, but
there are no new records in the table. Could someone tell me what I'm
doing wrong?


This is the code I've written:


'define variables
lgNeighCode = 5433
stAddress = "Road to nowhere"
stTransfer = "Me to You"
intClosedPrice = 5487

Dim sql As String
Dim rsAdd As New ADODB.Recordset

On Error GoTo DbError

'Open the Recordset object
rsAdd.Open "Temp", localConnection, adOpenDynamic, _
adLockBatchOptimistic, adCmdTable

'add the record based on input from the user
'gonna use stored variables
With rsAdd
.AddNew
!NeighCode = lgNeighCode
![Full Address] = stAddress
!Transfer = stTransfer
!Closed = intClosedPrice
.Update
.Close
End With

MsgBox "Record Should be added.", vbInformation

'close form-level recordset object and refresh
'it to include the newly updated row.

rsTransfers.Close
connectDB

Exit Sub


I've been stuck at this point for several days and I would greatly
appreciate any help.

Thanks

Keeage
 
G

Guest

Your code contains an on error goto .... Are you sure there is no typo in
your code that triggers this on error and lets you think evering went well?
 
K

Keeage

Thanks for your response,

I'm sure. I stepped throught the program and the goto error isn't
activated. Also the errorhandling only launches a a msgbox and that
would be hard to miss. I'm using VBA from office 2003.

Do I need to add any extra controls or plug-ins to interface with the
db. As I said, I can access the data and navigate through it, but I
can't add records.

Keeage

Your code contains an on error goto .... Are you sure there is no typo in
your code that triggers this on error and lets you think evering went well?
--
Gerwin Berentschot
(e-mail address removed).(nospam)
www.mraccess.nl



Keeage said:
I'm making a database that inputs large text files and stores the data.
I can connect to the db, display it's contents and navigate, but when
I try to add records, everything appears to function properly, but
there are no new records in the table. Could someone tell me what I'm
doing wrong?


This is the code I've written:


'define variables
lgNeighCode = 5433
stAddress = "Road to nowhere"
stTransfer = "Me to You"
intClosedPrice = 5487

Dim sql As String
Dim rsAdd As New ADODB.Recordset

On Error GoTo DbError

'Open the Recordset object
rsAdd.Open "Temp", localConnection, adOpenDynamic, _
adLockBatchOptimistic, adCmdTable

'add the record based on input from the user
'gonna use stored variables
With rsAdd
.AddNew
!NeighCode = lgNeighCode
![Full Address] = stAddress
!Transfer = stTransfer
!Closed = intClosedPrice
.Update
.Close
End With

MsgBox "Record Should be added.", vbInformation

'close form-level recordset object and refresh
'it to include the newly updated row.

rsTransfers.Close
connectDB

Exit Sub


I've been stuck at this point for several days and I would greatly
appreciate any help.

Thanks

Keeage
 
D

Douglas J. Steele

Where is localConnection defined? Are you sure you're looking in the correct
database for the results?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Keeage said:
Thanks for your response,

I'm sure. I stepped throught the program and the goto error isn't
activated. Also the errorhandling only launches a a msgbox and that
would be hard to miss. I'm using VBA from office 2003.

Do I need to add any extra controls or plug-ins to interface with the
db. As I said, I can access the data and navigate through it, but I
can't add records.

Keeage

Your code contains an on error goto .... Are you sure there is no typo in
your code that triggers this on error and lets you think evering went
well?
--
Gerwin Berentschot
(e-mail address removed).(nospam)
www.mraccess.nl



Keeage said:
I'm making a database that inputs large text files and stores the data.
I can connect to the db, display it's contents and navigate, but when
I try to add records, everything appears to function properly, but
there are no new records in the table. Could someone tell me what I'm
doing wrong?


This is the code I've written:


'define variables
lgNeighCode = 5433
stAddress = "Road to nowhere"
stTransfer = "Me to You"
intClosedPrice = 5487

Dim sql As String
Dim rsAdd As New ADODB.Recordset

On Error GoTo DbError

'Open the Recordset object
rsAdd.Open "Temp", localConnection, adOpenDynamic, _
adLockBatchOptimistic, adCmdTable

'add the record based on input from the user
'gonna use stored variables
With rsAdd
.AddNew
!NeighCode = lgNeighCode
![Full Address] = stAddress
!Transfer = stTransfer
!Closed = intClosedPrice
.Update
.Close
End With

MsgBox "Record Should be added.", vbInformation

'close form-level recordset object and refresh
'it to include the newly updated row.

rsTransfers.Close
connectDB

Exit Sub


I've been stuck at this point for several days and I would greatly
appreciate any help.

Thanks

Keeage
 
K

Keeage

I defined localConnection in my connectDB procedure, here is the code
for connectDB

Private Sub connectDB()

'Connect to CityAccess Database
Set localConnection = CurrentProject.AccessConnection
Dim sql As String
On Error GoTo DbError

sql = "select * from Temp"
rsTransfers.Open sql, localConnection, adOpenDynamic,
adLockBatchOptimistic, adCmdText
If rsTransfers.EOF = False Then
MsgBox "It's Workin'"
lbloutput.Caption = rsTransfers![Full Address]

End If
Exit Sub


and I have it declared in the general declarations:

Dim localConnection As ADODB.Connection

Keeage

Where is localConnection defined? Are you sure you're looking in the correct
database for the results?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Keeage said:
Thanks for your response,

I'm sure. I stepped throught the program and the goto error isn't
activated. Also the errorhandling only launches a a msgbox and that
would be hard to miss. I'm using VBA from office 2003.

Do I need to add any extra controls or plug-ins to interface with the
db. As I said, I can access the data and navigate through it, but I
can't add records.

Keeage

Your code contains an on error goto .... Are you sure there is no typo in
your code that triggers this on error and lets you think evering went
well?
--
Gerwin Berentschot
(e-mail address removed).(nospam)
www.mraccess.nl



:

I'm making a database that inputs large text files and stores the data.
I can connect to the db, display it's contents and navigate, but when
I try to add records, everything appears to function properly, but
there are no new records in the table. Could someone tell me what I'm
doing wrong?


This is the code I've written:


'define variables
lgNeighCode = 5433
stAddress = "Road to nowhere"
stTransfer = "Me to You"
intClosedPrice = 5487

Dim sql As String
Dim rsAdd As New ADODB.Recordset

On Error GoTo DbError

'Open the Recordset object
rsAdd.Open "Temp", localConnection, adOpenDynamic, _
adLockBatchOptimistic, adCmdTable

'add the record based on input from the user
'gonna use stored variables
With rsAdd
.AddNew
!NeighCode = lgNeighCode
![Full Address] = stAddress
!Transfer = stTransfer
!Closed = intClosedPrice
.Update
.Close
End With

MsgBox "Record Should be added.", vbInformation

'close form-level recordset object and refresh
'it to include the newly updated row.

rsTransfers.Close
connectDB

Exit Sub


I've been stuck at this point for several days and I would greatly
appreciate any help.

Thanks

Keeage
 

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