Hi I have this embedded macro that is attached to a command button on my Form. I need this to be VBA code since I have to add a step to execute a select query that checks records against 2 tables to see if the record on my Temp table already has the same records on the "real" table. I also have to display a message to the user if the records already exist and if they don't continue with the process. I know how to convert a macro to VBA code, however, I think I need to use the .execute method and I am not sure how to code it.
Here's my converted macro:
Would you help me convert to the correct VBA code so it runs through the first 2 queries and then based on the results of the 2nd query continues with the rest of the steps. So If the record count from the 2nd query >0 display a message and stop processing Else continue with the steps and display message that the records were attested.
From my previous post yesterday, a gentleman (arnelgp) was able to help me create this VBA module that is attached to a different form's control button. I think I would have to used this type of process and statements.
Private Sub Command82_Click()
Dim db As DAO.Database
Dim p As Parameter
Set db = CurrentDb
With db
With .QueryDefs("qryDeleteRecsFromTempImport")
For Each p In .Parameters
p = Eval(p.Name)
Next
.Execute
End With
With .QueryDefs("qryImportClaimsFromCYBER")
For Each p In .Parameters
p = Eval(p.Name)
Next
.Execute
If .RecordsAffected <> 0 Then
MsgBox .RecordsAffected & " Claims successfully imported from CYBER."
Else
MsgBox "No Claims were imported from CYBER."
End If
End With
End With
End Sub
Thank you - Ann Marie
Here's my converted macro:
Would you help me convert to the correct VBA code so it runs through the first 2 queries and then based on the results of the 2nd query continues with the rest of the steps. So If the record count from the 2nd query >0 display a message and stop processing Else continue with the steps and display message that the records were attested.
From my previous post yesterday, a gentleman (arnelgp) was able to help me create this VBA module that is attached to a different form's control button. I think I would have to used this type of process and statements.
Private Sub Command82_Click()
Dim db As DAO.Database
Dim p As Parameter
Set db = CurrentDb
With db
With .QueryDefs("qryDeleteRecsFromTempImport")
For Each p In .Parameters
p = Eval(p.Name)
Next
.Execute
End With
With .QueryDefs("qryImportClaimsFromCYBER")
For Each p In .Parameters
p = Eval(p.Name)
Next
.Execute
If .RecordsAffected <> 0 Then
MsgBox .RecordsAffected & " Claims successfully imported from CYBER."
Else
MsgBox "No Claims were imported from CYBER."
End If
End With
End With
End Sub
Thank you - Ann Marie