Hi,
I have an Excel sheet with two columns:
projectName and CircuitID.
Circuit ID is in the format:
13-Location1-Location2-001
In Access, i made a table with these columns:
projectName, CircuitID, Loc1,Loc2,State1,State2
The first two columns (projectName and CircuitID) will be filled in from my Excel data.
The other 4 columns can be calculated.
i created a form (frmCircuits) with a sub called Sub1 to fill in the other 4 values:
Dim Dash As String
Dim findDash1
Dim findDash2
Dash = "-"
'this looks for the first dash in the string Circuit. it returns the position of
'that number to the variable called FindDash1. that is a way to find the first location.
findDash1 = InStr(1, Circuit, Dash, vbTextCompare)
'this looks for the second dash in the string Circuit. it returns the position of
'that number to the variable called FindDash2. that is a way to find the second location.
findDash2 = InStr(findDash1 + 1, Circuit, Dash, vbTextCompare)
Me.Loc1 = Trim(Mid(Circuit, findDash1 + 1, 3))
Me.Loc2 = Trim(Mid(Circuit, findDash2 + 1, 3))
'uses the Loc1 and Loc2 fields to look in the table
'tblAddress to find the State.
Me.State1 = DLookup("State", "tblAddress", "[Site Code] Like " & "'" & Forms![frmCircuits]![Loc1] & "*" & "'"
Me.State2 = DLookup("State", "tblAddress", "[Site Code] Like " & "'" & Forms![frmCircuits]![Loc2] & "*" & "'"

End Sub
At the moment, i have the Form_Current and Circuit_AfterUpdate calling this function.
Everything works fine, but you have to click with the mouse on the specific record for the Loc1, Loc2, State1 and State2 fields to get filled in.
Because otherwise, the on_current event isn't getting triggered.
Am i doing this the wrong way?
thanks,
ruth ruth.jonkman@wcom.com