So I have this database that I need to add functionality to. I am creating a new form that draws information from a hidden subform and from some tables. I have several labels on this new form that need to be updated based on the record that the subform is opened at.
Here is what I used initially to update two labels. The value for one comes directly from the subform while the value for the other one comes from a table, based on the first label. It works well.
I now need to add additonal info to the new form based on the value of a variable on the same subform. I have added this code to the original
When I run it I get a "duplicate declaration in current scope" error.
If I comment out this:
I get no error, but the labels do not change and the messageboxes do not pop on the screen either.
suggestions?
Thanks
mafhobb
Here is what I used initially to update two labels. The value for one comes directly from the subform while the value for the other one comes from a table, based on the first label. It works well.
Code:
'change the SKU label caption to show SKU#
lblSKU.Caption = Nz(Forms![contacts]![Call Listing Subform].Form![SKU], "No SKU Loaded")
'find SKU message if it exists
Dim SKUMess As String
SKUMess = lblSKU.Caption
Dim db As dao.Database
Dim rs As dao.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tblSKUMessage", dbOpenDynaset)
rs.FindFirst "[SKU#]='" & SKUMess & "'"
If rs.NoMatch = True Then
Exit Sub
End If
'Make the SKUmessage box visible and display the SKU message if it exists
txtmessage.Value = rs!SKUMessage
txtmessage.Visible = True
BoxMess.Visible = True
'reset recordset
Set db = Nothing
Set rs = Nothing
'Done with SKU Message Box
I now need to add additonal info to the new form based on the value of a variable on the same subform. I have added this code to the original
Code:
'Figure out the Customer ID
'What is the CallID from subform "Call Listing subfom"
Dim CallIDvar As Long
CallIDvar = Forms![contacts]![Call Listing Subform].Form![CallID]
MsgBox CallIDvar
'find contactID based on CallID using the
Dim db As dao.Database
Dim rs As dao.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("Calls", dbOpenDynaset)
rs.FindFirst "[CallID]='" & CallIDvar & "'"
If rs.NoMatch = True Then
Exit Sub
End If
MsgBox ContactID
'Make the lblCustID the same as the ContactID in the calls table
lblCustID.Value = rs!ContactID
'reset recordset
Set db = Nothing
Set rs = Nothing
'Done with ContactID labe
When I run it I get a "duplicate declaration in current scope" error.
If I comment out this:
Code:
' Dim db As dao.Database
' Dim rs As dao.Recordset
' Set db = CurrentDb
suggestions?
Thanks
mafhobb