AssetManagement
New member
- Local time
- Today, 14:38
- Joined
- Dec 10, 2012
- Messages
- 2
Hello, I am new to Access and I am trying to put a condition on a form button using VB.
What I am trying to is to take a field on a form (HistoryEntry.Barcode) and have it compared to the Asset table to verify that the barcode exist (Barcode is the column name).
If it exists, it will insert all the information on the form into the History table. If it does not it will return a message box.
I know that in SQL I could use the
IF exists (select * from Assets where barcode = HistoryEntry.Barcode) then
insert into History (columnnames) values (columnvalues).
Currently my VB does (This is the standard button macro in Access):
Private Sub Add_Asset_History_Click()
On Error GoTo Add_Asset_History_Click_Err
On Error Resume Next
DoCmd.GoToRecord , "", acNewRec
If (MacroError <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
End If
Add_Asset_History_Click_Exit:
Exit Sub
Add_Asset_History_Click_Err:
MsgBox Error$
Resume Add_Asset_History_Click_Exit
End Sub
What I am trying to is to take a field on a form (HistoryEntry.Barcode) and have it compared to the Asset table to verify that the barcode exist (Barcode is the column name).
If it exists, it will insert all the information on the form into the History table. If it does not it will return a message box.
I know that in SQL I could use the
IF exists (select * from Assets where barcode = HistoryEntry.Barcode) then
insert into History (columnnames) values (columnvalues).
Currently my VB does (This is the standard button macro in Access):
Private Sub Add_Asset_History_Click()
On Error GoTo Add_Asset_History_Click_Err
On Error Resume Next
DoCmd.GoToRecord , "", acNewRec
If (MacroError <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
End If
Add_Asset_History_Click_Exit:
Exit Sub
Add_Asset_History_Click_Err:
MsgBox Error$
Resume Add_Asset_History_Click_Exit
End Sub