473,505 Members | 13,982 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dlookup value based upon lookup selection

11 New Member
Hello Folks

I am using Microsoft Access 2000

I would be grateful if someone could help me with “Dlookup”. I tried various methods of writing Dlookup and various events to trigger it, none of which were successful. I have been able to display the required value in a ‘text box’ which is a little helpful but not ideal.

I have a table called tblLogSheet. The ‘Description’ field of this table uses a lookup table called tblLkUpDescription. tblLkUpDescription contains two fields. The first field is called, ‘Equipment’ and the second field is called ‘Insulation’. I have a form called ‘frmNew_Appliance’. This form is used to input new records into tblLogSheet. The data entry clerk selects an item of equipment from the drop down list of the combo box, derived from the ‘Equipment’ field of the lookup table. The selection is entered into the ‘Description’ field of tblLogSheet via the frmRecord_New_Appliance input form. I would like the value listed in tblLkUpDescription, ‘Insulation’ field, which is adjacent to the selection made by the data entry clerk from the ‘Equipment’ field, to be entered automatically into my ‘Insulation_check’ field. The ‘Insulation_check’ field is on my frmRecord_New_Appliance. This automated entry will update the tblLogSheet with the ‘Insulation_Check’ recording.

Please note - The clerk can write to the ‘Description’ field as appropriate selection may not be available in list. All fields are text fields. The number of descriptions listed in tblLkUpDescription table is currently 356. The ‘Description’ field name property is Combo128. The form is Single Form

tblLkUpDescription
The first field is: - ‘Equipment’ Field list – (This provides selections for ‘Description’ Field)
The Second field: - ‘Insulation’ Field (Contains the Value Required)

tblLogSheet
‘Description’ Field - (Records the Combo Selection - derived from ‘Equipment’ field list)
‘Insulation_Check’ field - (Needs Auto Entry Of adjacent value from Insulation Field)

Data entry for tblLogSheet is performed via ‘frmRecord_New_Appliance’

Many thanks to anyone kind enough to reply
Jan 14 '09 #1
6 5167
puppydogbuddy
1,923 Recognized Expert Top Contributor
David,

Place the following code behind frmRecord_New_Appliance. Replace the illustrative object names used with their actual names in your application....for example, replace YourCombobox with the actual name of yourCombobox.

Expand|Select|Wrap|Line Numbers
  1. Private Sub YourCombobox_AfterUpdate()
  2. Me!YourCombobox.Requery
  3. 'selection from combobox used to update tblLogSheet
  4. tblLogSheet.Equipment = Me!YourCombobox.Column(0)
  5. tblLogSheet.Insulation = Me!YourCombobox.Column(1)
  6. End Sub
  7.  
Jan 15 '09 #2
David Wright
11 New Member
Thank you puppy dog buddy. I am affraid it did not work for me. I tried the following:

Attempt 1
Combo128 AfterUpdate

Private Sub Combo128_AfterUpdate()
Me!Combo128.Requery
'selection from combobox used to update tblLogSheet
tblLogSheet.Description = Me!Combo128(0)
tblLogSheet.Insulation_Check = Me!Combo128(1)
End Sub

When I entered data into my form, the following was presented:
Run-time error ‘451’
Property let procedure not defined and property get procedure did not return an object.

When I clicked on Debug, the following line was highlighted
tblLogSheet.Description = Me!Combo128(0)

Attempt 2

Because I am selecting the description from the dropdown list which the ‘Description’ field uses as a lookup; I tried removing one line of code. I hoped that it would then run and record the value from the second field of the lookup table (referred to as (1) ) into the Insulation_Check field. This did not work and the same error message was presented to me.

Attempt 3
I tried entering the code into the After Update event procedure of the form frmRecord_New_appliance

Private Sub Form_AfterUpdate()
Private Sub Combo128_AfterUpdate()
Me!Combo128.Requery
'selection from combobox used to update tblLogSheet
tblLogSheet.Description = Combo128(0)
tblLogSheet.Insulation_Check = Me!Combo128(1)
End Sub

I received a run time error 13 – Type mismatch

Then I tried this:

In Form Afterupdate

Private Sub Form_AfterUpdate()
Me!Combo128.Requery
'selection from combobox used to update tblLogSheet
tblLogSheet.Description = Combo128(0)
tblLogSheet.Insulation_Check = Me!Combo128(1)
End Sub

No error message came up but the required ‘automated’ entry was not made into the Insulation_Check field.

Is there anything else you suggest? The tblLogsheet does have other fields one of which is a primary key field. Regards David
Jan 15 '09 #3
puppydogbuddy
1,923 Recognized Expert Top Contributor
David,
this is in response to your first attempt...you did not completely follow the syntax I gave you.
Expand|Select|Wrap|Line Numbers
  1. Change this:
  2. tblLogSheet.Description = Me!Combo128(0)
  3. tblLogSheet.Insulation_Check = Me!Combo128(1)
  4.  
to this;
Expand|Select|Wrap|Line Numbers
  1. tblLogSheet.Description = Me![Combo128].Column(0)
  2. tblLogSheet.Insulation_Check = Me![Combo128].Column(1)
  3.  
Also, note that wherever you have spaces in an object name like Combo 128, you have to enclose the name in brackets [Combo 128].

After you make all of the above suggested changes, get back to me.
Jan 15 '09 #4
David Wright
11 New Member
Hello PuppyDog

Thank you for writing again. I tried what you suggested and this is the result.

Private Sub Combo128_AfterUpdate()
Me!Combo128.Requery
'selection from combobox used to update tblLogSheet
tblLogSheet.Description = Me![Combo128].Column(0)
tblLogSheet.Insulation_Check = Me![Combo128].Column(1)

End Sub

Run time error ‘424’
Object Required
Jan 15 '09 #5
puppydogbuddy
1,923 Recognized Expert Top Contributor
oops, I used the bang operator, where I should have used the dot operator. If you still get an error try to identify the error line.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo128_AfterUpdate()
  2. Me.Combo128.Requery
  3. 'selection from combobox used to update tblLogSheet
  4. tblLogSheet.Description = Me.[Combo128].Column(0)
  5. tblLogSheet.Insulation_Check = Me.[Combo128].Column(1)
  6.  
  7. End Sub
  8.  
Jan 15 '09 #6
David Wright
11 New Member
Hello PuppyDogPal
I now have the answer thanks to your guidance. Please see below:

Private Sub Combo128_AfterUpdate()
Me.Combo128.Requery
'selection from combobox used to update tblLogSheet
Forms!frmRECORD_NEW_APPLIANCE!Description = Me.[Combo128].Column(0)
Forms!frmRECORD_NEW_APPLIANCE!Insulation_Check = Me.[Combo128].Column(1)

End Sub

I could not have got there without your help. Many, many thanks David.
Jan 16 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
5227
by: mstery | last post by:
I have a report generated via an ID selection made in a dropdown on a form. The report filters by an on click event in a preview report button on the form. Everything in the report, including...
4
2482
by: basstwo | last post by:
I have a field with a serial number in it. I want to use Mid to extract the 4th and 5th characters, use them to lookup a value on a small lookup table, and use the info from that table to fill in...
8
4304
by: Christine Henderson | last post by:
I have a problem using the above function in the following simplified circumstance: In the lookup table called "Klms Travelled" I have 3 fields, eg: Receiver Name Receiver Suburb ...
3
1552
by: mmorgan1240 | last post by:
I have a form that I am trying to update. I would like to have a field populated by another table (State_laws) based on the value of another field on the form. I have a field called "state". When...
1
1785
by: aharding | last post by:
Hello! I am using Access 2003 I have been playing with DLookup all morning and have not been successful yet. I have never used this function...and have some limited experience with code. I...
2
2050
by: Alan | last post by:
OK, I have a table called tblPVDMatch with a list of customerID's in it. I want to perform a lookup on this table to display a message box if the CustomerID field on the form matches an entry in...
2
1777
by: Randy | last post by:
Hi, I'm trying to populate textbox values upon a change in a combobox selection. I'm using the Publishers table in the Pubs sample database as a simplified example. Here is the code: Private...
0
2688
by: solargovind | last post by:
Hello, I have few problem with Dlookup condition. I need to retrieve next record or previous record based on certain condition. The conditions are set in in the combo box. Here, I am trying to...
15
3087
by: rleepac | last post by:
This is a little complicated but I'll do my best to explain. In my db I have a table called L_AgeCorrection which has the following fields: Age, Sex, Frequency, AgeValue This is a table used to...
0
7216
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7303
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7018
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5613
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4699
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.