I am new to VB coding and am having two problems with DLookup function which I am unable to solve.
I have two tables, Patient and Surgeons, linked by SurgeonID. On a Patients form I have a combo box which populates the surgeons last name. I am trying to populate text boxes for a surgeon identifier called SurgeonULI (long integer) and an additional text field in my Patients form from the Surgeons table.
Part of the code being used is as follows:
TempULI = DLookup("[SurgeonULI]", "Surgeons", "[SurgeonLastName}='" & [Forms]![Patient]![SurgeonLastName] & "'"
Me!SurgeonULI.SetFocus
SurgeonULI = TempULI
On execution I receive a null error even though the SurgeonLastName is entered approrpiately. Why is this??
Second issue. When I execute this sub, a new entry appears in my Patient table. It enters the appropriate SurgeonID as the SurgeonLastName. How do I stop this from happening?
Thanks in advance
I have two tables, Patient and Surgeons, linked by SurgeonID. On a Patients form I have a combo box which populates the surgeons last name. I am trying to populate text boxes for a surgeon identifier called SurgeonULI (long integer) and an additional text field in my Patients form from the Surgeons table.
Part of the code being used is as follows:
TempULI = DLookup("[SurgeonULI]", "Surgeons", "[SurgeonLastName}='" & [Forms]![Patient]![SurgeonLastName] & "'"
Me!SurgeonULI.SetFocus
SurgeonULI = TempULI
On execution I receive a null error even though the SurgeonLastName is entered approrpiately. Why is this??
Second issue. When I execute this sub, a new entry appears in my Patient table. It enters the appropriate SurgeonID as the SurgeonLastName. How do I stop this from happening?
Thanks in advance