drrocket5292
Technical User
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
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