473,503 Members | 12,003 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dlookup Field Not Saving

8 New Member
I have an Acess database with a lookup field, the lookup is working correctly on the form, it accesses another table called raw materials for the information.

=DLookUp("[£ Per Kg]","[Raw Materials]","[ID]=[material (main)]")

The Dlookup field is not saving to the Input table which is linked to the form.

What am I doing wrong?
Oct 4 '07 #1
15 4490
MikeTheBike
639 Recognized Expert Contributor
I have an Acess database with a lookup field, the lookup is working correctly on the form, it accesses another table called raw materials for the information.

=DLookUp("[£ Per Kg]","[Raw Materials]","[ID]=[material (main)]")

The Dlookup field is not saving to the Input table which is linked to the form.

What am I doing wrong?
Hi

Moore information required.

Where/how are you using =DLookUp("[£ Per Kg]","[Raw Materials]","[ID]=[material (main)]")

Is the form bound, if so, to what table.
Where/how are you trying to save the lookup value
etc.

MTB
Oct 5 '07 #2
paullofthouse
8 New Member
I am putting the dlookup command in the control source of field Main Mat £ Per Kg on a form called data input form.

I think the form is bound to the input table, but the Dlookup field is trying to pull the price from the Raw Materials table.

It compares the Material Main field value in the data input form to the £ Per Kg field on the Raw Materials table.

The Dlookup works fine on the input form, but when it is saved the value that the Dlookup query has found is not saving to the Input Table, the field is just blank. Does it have to be connected in some way?.
Oct 8 '07 #3
MikeTheBike
639 Recognized Expert Contributor
I am putting the dlookup command in the control source of field Main Mat £ Per Kg on a form called data input form.

I think the form is bound to the input table, but the Dlookup field is trying to pull the price from the Raw Materials table.

It compares the Material Main field value in the data input form to the £ Per Kg field on the Raw Materials table.

The Dlookup works fine on the input form, but when it is saved the value that the Dlookup query has found is not saving to the Input Table, the field is just blank. Does it have to be connected in some way?.
Hi again

If you are entering a new record, then try putting this
=DLookUp("[£ Per Kg]","[Raw Materials]","[ID]=[material (main)]")
in the DEFAULT value of the [Main Mat £ Per Kg] control (not the Control Source), and set the Control Source as the field you want to save it in, ie. bind it to [Main Mat £ Per Kg]. Assuming the form is bound to this table!

See if that does it.


MTB
Oct 8 '07 #4
paullofthouse
8 New Member
Hi,

Tried that it just puts £0.000 in the Main Mat £ Per Kg field, am I doing something wrong?

Paul
Oct 8 '07 #5
MikeTheBike
639 Recognized Expert Contributor
Hi,

Tried that it just puts £0.000 in the Main Mat £ Per Kg field, am I doing something wrong?

Paul
Hi

We seem to be missing something

Are you trying to save a NEW record?

If so, then what value is displayed in the control before it is saved; is it the one you expect?

Where is the value of [material (main)] (in "[ID]=[material (main)]") coming from ?

MTB
Oct 9 '07 #6
paullofthouse
8 New Member
Hi, Thanks for help so far.

Yes I am trying to save a new record

The value in Main Mat £ Per Kg now is £0.000, this is in the form before it is saved and this amount gets saved onto the table.

Have put the default value as my Dlookup information and the control source has the Main Mat £ Per Kg, Dlookup does not seem to work unless it is in control source field, then it does not save.

Material (Main) is a combo box in the same input form, (main mat £ per kg was also a combo box before I started with Dlookup).

ID is an id code, this is in the Raw materials table.

What I am trying to acheive is for the Main Mat £ Per Kg field to auto complete with the price from the Raw Materials table. It needs to lookup the value of material main in the ID column and then extract the price.
Oct 9 '07 #7
MikeTheBike
639 Recognized Expert Contributor
Hi, Thanks for help so far.

Yes I am trying to save a new record

The value in Main Mat £ Per Kg now is £0.000, this is in the form before it is saved and this amount gets saved onto the table.

Have put the default value as my Dlookup information and the control source has the Main Mat £ Per Kg, Dlookup does not seem to work unless it is in control source field, then it does not save.

Material (Main) is a combo box in the same input form, (main mat £ per kg was also a combo box before I started with Dlookup).

ID is an id code, this is in the Raw materials table.

What I am trying to acheive is for the Main Mat £ Per Kg field to auto complete with the price from the Raw Materials table. It needs to lookup the value of material main in the ID column and then extract the price.
Hi

I think the Defult Value should be

=DLookUp("[£ Per Kg]","[Raw Materials]","[ID]=” & [material (main)])
not
=DLookUp("[£ Per Kg]","[Raw Materials]","[ID]= [material (main)]")

This will look at the VALUE of the Form Control named [material (main)] ie. the ComboBox(?), and not the string "[material (main)]"


??
MTB
Oct 9 '07 #8
paullofthouse
8 New Member
Hi, tried what you said.

Unfortunately it came up with name? error message in the main Mat £ per kg field and then went to £0.000 when something was entered in the material (main) field. material main is text box and id is a number field.
Oct 9 '07 #9
MikeTheBike
639 Recognized Expert Contributor
Hi, tried what you said.

Unfortunately it came up with name? error message in the main Mat £ per kg field and then went to £0.000 when something was entered in the material (main) field. material main is text box and id is a number field.
Hi

The Name? error means that the [material (main)] control/field name was not recognised.

However, even when this method method is sorted, I don't think it will not do what you want because it will only work with the default value of the of the [material (main)] ComboBox, and changing the value will not change the value in the [Main Mat £ Per Kg] control.

So what I suggest is puting this code in the [Main Mat £ Per Kg] control After Upade event

If Me.NewRecord Then [Main Mat £ Per Kg] = DLookUp("[£ Per Kg]","[Raw Materials]","[ID]=” & [material (main)])

MTB
Oct 10 '07 #10
paullofthouse
8 New Member
Tried this and it did not work, got no error messages but it did not update the field in the table, ot was just £0.00
Oct 10 '07 #11
MikeTheBike
639 Recognized Expert Contributor
Tried this and it did not work, got no error messages but it did not update the field in the table, ot was just £0.00
Hi

It would appear you are still having trouble getting the DLookup to work.
I don't know what your ComboBox is named, but if it is material__main_, then try this and see what you get.
Expand|Select|Wrap|Line Numbers
  1. Private Sub material__main__AfterUpdate()
  2.     MsgBox DLookup("[£ Per Kg]", "[Raw Materials]", "ID=" & material__main_)
  3. End Sub
If its not material__main_ then substitue whatever name you have used.

MTB
Oct 11 '07 #12
paullofthouse
8 New Member
HI, sorry for not getting back, been on holiday.

Where do I need to put this code?

Paul.
Oct 22 '07 #13
MikeTheBike
639 Recognized Expert Contributor
HI, sorry for not getting back, been on holiday.

Where do I need to put this code?

Paul.
Hi

If you go to the Events tab of the ComboBox properties dialog and select [Event Procedure] for the the After Update event. Then click the button next to the event field. This will go to the code module AfterUpade code where you can put the DLookup in my last post.

MTB
Oct 23 '07 #14
missinglinq
3,532 Recognized Expert Specialist
I've gotten dizzy trying to follow all the permutaions y'all have tried! But I think the following might help!

You say that

Expand|Select|Wrap|Line Numbers
  1.  =DLookUp("[£ Per Kg]","[Raw Materials]","[ID]=[material (main)]")
  2.  
works fine on your form, Where does it appear on your form (in a textbox? what name?) and how are you causing it to appear?

Using the DLookup as a default value won't work, I don't think, because a default value is "entered" when a new record is first invoked, and at that point the "material" that is the criteria for the function has not been entered in the new record. Hence the value of zero pounds. Before trying the following, be sure to remove the DLookup from wherever you currently have it, especially from the Default property.

I think what you need to do is, in the AfterUpdate event of the control where the main material is entered, use the DLookup to assign the cost per Kg:

Expand|Select|Wrap|Line Numbers
  1. Private Sub MainMaterial_AfterUpdate()
  2.   Me.MainMaterialPerKgCost =DLookUp("[£ Per Kg]","[Raw
  3. Materials]","[ID]=[material (main)]")
  4. End Sub
  5.  
Welcome to TheScripts, Paul!

Linq ;0)>
Oct 23 '07 #15
paullofthouse
8 New Member
Hi thanks for that I have finally managed to do what I want.

Put the code you suggested in the after update of material (main) and tested and it seems to be updating fine. On both the form and the table.

Never used Access before and was tearing my hair out at this problem.

Thanks again
Paul.
Oct 24 '07 #16

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

Similar topics

1
20742
by: KLAU | last post by:
I have a field that retrieves information from an expression in a query. I have used a DLookup function to get the calculated field from the query. However, the relationship is 1-to-many so one...
6
2323
by: JLM | last post by:
What am I missing here? I have a form where I enter a "Class Code". This value corresponds to what sits in table "class code descriptions" along with the "title" of each "class code." Key...
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
2480
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 ...
6
508
by: Don Sealer | last post by:
I've written this expression for a DLookup function. It works almost alright. What I'm trying to do is type in a description and the ID field (number) populates automatically. It works almost as...
1
2394
by: MLH | last post by:
I have a query that looks up records in tblReturnReceipts and other related tables. One of the other tables is tblCorrespondence. The resulting dynaset consists of five records. Each has a unique ...
21
3323
by: Thelma Lubkin | last post by:
I would like my DLookup criteria to say this: Trim(fieldX) = strVar: myVar = _ DLookup("someField", "someTable", "Trim(fieldX) = '" & strVar & '") I don't believe that this will work, and I...
1
1618
by: Deac | last post by:
I was asked to help a friend with a database and am in over my head! The customer table has been in place and they have used a paper copy of the pricing table to make manual changes and...
0
7193
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
7264
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
7316
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
6975
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
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5562
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,...
1
4992
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
371
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.