A
Austin Bike
I am having a problem. I want to create an onExit function for a
field on a form. If the field (manufacturer) is equal to one value, I
want to do a dlookup in one table and return a value sales rep.
However, if the input is NOT equal to that value, I want to do a
dlookup on a different table and return a different value to the sales
rep field.
We have 2 types of sales reps, regular and specialist. Each
transaction has one regular sales rep and one specialist.
Half of the specialists are assigned to one vendor, so their names are
kept in the vendor table. However, one vendor has multiple
specialists, so their names are kept in the sales rep table.
Here's the code I am trying to use:
Private Sub Manufacturer_Exit(Cancel As Integer)
If Me.Manufacturer = "Microsoft" Then
Dim varCOC As Variant
varCOC = DLookup("MSFT", "ISR", "ISR =[ISR] ")
If (Not IsNull(varCOC)) Then Me![COC] = varCOC
Else
Dim varCOC As Variant
varCOC = DLookup("Specialist_name", "Vendors", "Manufacturer
=[Dell S&P Vendor] ")
If (Not IsNull(varCOC)) Then Me![COC] = varCOC
End If
End Sub
Each statement works on its own, but when you combine the two together
with an "else" it chokes and tells me that "Dim varCOC As Variant" has
already been used.
Thanks in advance.
field on a form. If the field (manufacturer) is equal to one value, I
want to do a dlookup in one table and return a value sales rep.
However, if the input is NOT equal to that value, I want to do a
dlookup on a different table and return a different value to the sales
rep field.
We have 2 types of sales reps, regular and specialist. Each
transaction has one regular sales rep and one specialist.
Half of the specialists are assigned to one vendor, so their names are
kept in the vendor table. However, one vendor has multiple
specialists, so their names are kept in the sales rep table.
Here's the code I am trying to use:
Private Sub Manufacturer_Exit(Cancel As Integer)
If Me.Manufacturer = "Microsoft" Then
Dim varCOC As Variant
varCOC = DLookup("MSFT", "ISR", "ISR =[ISR] ")
If (Not IsNull(varCOC)) Then Me![COC] = varCOC
Else
Dim varCOC As Variant
varCOC = DLookup("Specialist_name", "Vendors", "Manufacturer
=[Dell S&P Vendor] ")
If (Not IsNull(varCOC)) Then Me![COC] = varCOC
End If
End Sub
Each statement works on its own, but when you combine the two together
with an "else" it chokes and tells me that "Dim varCOC As Variant" has
already been used.
Thanks in advance.