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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update table immediately?

Status
Not open for further replies.

drrocket5292

Technical User
Sep 6, 2005
73
US
Hi,
I know you guys get this all the time but I'm new to VBA programming and I'm trying to set up a database at work. I have written code that works for what I'm trying to do but for some reason now it doesnt update the table until after I close the form. would someone mind reading my code and telling me if there's a command I could put in it that would allow the results to go into the table immediately? thanks for the help.


Private Sub Command50_Click()
On Error GoTo Err_Command50_Click

Dim dbms As ADODB.Connection
Dim rst As ADODB.Recordset
Set dbms = CurrentProject.Connection
Dim acin As Double


acin = Me![Account10]

Set rst = New ADODB.Recordset
rst.Open "account1", dbms, adOpenKeyset, adLockOptimistic

rst.MoveFirst
rst.Find "account =" & acin

If rst.EOF Then
rst.AddNew
MsgBox ("Thank you for updating this MSB.")

Else
MsgBox ("This account has already been updated." & _
vbCrLf & _
"Please delete it using the delete button & _
vbcrlf & _
before trying to update it again.")

End If




Exit_Command50_Click:
Exit Sub

Err_Command50_Click:
MsgBox Err.Description
Resume Exit_Command50_Click

End Sub
 
maybe

If rst.EOF Then
rst.AddNew
rst.update
MsgBox ("Thank you for updating this MSB.")

Else


I assume you are using bound controls and that the information is correctly entered on the screen at this stage.



Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Perhaps at least this ?
rst.AddNew
rst("account") = acin
rst.Update

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top