Access 2013 Dlookup issue

28 Views Asked by At

good morning all I usually find the answer to my queries already on here but this one has me stumped. I have 3 tables, area containing Area and Region, Phones comtaining phone number and IMSI (SIM number) and a log containing all 4 fields. I've put in a Dlookup (as found on this site) on the log and although it works the first time the event is triggered it allways comes up with the wrong value. It's probably something stupid and simple, it's years since I used Access and that was probably Access 2007 or something.

Hope you can help. I have created a cut down test version but not sure how to add it to the question.

The VB code is here

Private Sub Area_Change() 
Dim FoundRegion As String 
FoundRegion = DLookup("[Region]", "[Area]", "'[Area]![Area]=[Area]'") 
Me.Region = FoundRegion 
End Sub 
Private Sub Phone_Number_AfterUpdate() 
Dim FoundIMSI As Double 
FoundIMSI = DLookup("[IMSI ]", "[phones]", "'[phones]![Phone Number]=[Phone Number]'") 
Me.IMSI = FoundIMSI 
End Sub 

not sure how to add the database

1

There are 1 best solutions below

1
On

Private Sub Area_Change() Dim FoundRegion As String FoundRegion = DLookup("[Region]", "[Area]", "'[Area]![Area]=[Area]'") Me.Region = FoundRegion End Sub

Private Sub Phone_Number_AfterUpdate() Dim FoundIMSI As Double FoundIMSI = DLookup("[IMSI ]", "[phones]", "'[phones]![Phone Number]=[Phone Number]'") Me.IMSI = FoundIMSI End Sub