By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,377 Members | 493 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,377 IT Pros & Developers. It's quick & easy.

INDIRECT command in excel quivalent in Access

P: 8
Bit uninformed with these kinds of things. I have a huge project with load of combo boxes, but if i can just use a simple example of what I am trying to achieve.

in Access 2007 -Lets say I am trying to do quote. I have two tables; one is called Proofs, the other Quote. In the proofs table, I have proof ID, then Proof type, then price. In my quote I have proof type and then price, and then total.

So in the quote table, in the proof type column, I have a combo box where you can select from the "proofs table" what size you want.

A4
A3

In the proofs table, A4’s price is 0.84 and the A3 is 1.52. What I am trying to do on Form View, when I have created an order form, is tell it to automatically pick up the price of what is selected, like you would do in excel with indirect command. So if I select A4, then in the price column, it will automatically give me the price of 0.84 in the price column.

Does that make sense to anyone? I can do it in excel, but I don’t know how to do it in access. I have tried dlookup, but my knowledge of VB is not too good.
May 27 '10 #1

✓ answered by ChipR

You can find a lot of what you need on Microsoft's reference websites, in this case: DLookup Function (http://office.microsoft.com/en-us/ac...288251033.aspx)
DLookup(expr, domain [, criteria] )
So I was just being lazy, referring to the criteria and not wanting to retype the rest. This function is particularly useful, so check out that page thoroughly and let us know if you still have problems.

Share this Question
Share on Google+
8 Replies

Expert 100+
P: 1,287
Assuming your combo box is bound to the column containing ProofType, you could try something like:
Expand|Select|Wrap|Line Numbers
  1. Private Sub ProofSizeComboBox_AfterUpdate()
  2.  
  3. PriceTextBox = DLookup("Price", "Proofs", _
  4.  "ProofType = """ & ProofSizeComboBox & """")
  5.  
  6. End Sub
May 28 '10 #2

P: 8
Thank you so much. I am going to try it.

Kind regards
May 31 '10 #3

P: 8
@ChipR
Hi, me again.

i have two tables:

Table 1 is called Proofs and it has three fields, Proofs (which is the primary), Proof ID, Price ID.

Then in my second table, (which I have created a form for) I have:
Quotes ID, Proof (this is where I have a combo box to select between A4 and A3), and then the next field is Price (where I want to use your formula you gave me) and then Total field. I am not concerned about the Total, I know how to get Price and Total to add up.

So I did this in VB:

Private Sub ProofSizeComboBox_AfterUpdate()

Price = DLookup("Price", "Proofs", "ProofID = """ & ProofIDComboBox & """")

End Sub

But nothing happened. What am I doing wrong?

Kind regards
Romes
May 31 '10 #4

P: 8
@ChipR
Hi, is there some way I can upload the file?
May 31 '10 #5

Expert 100+
P: 1,287
Hi romes. It shouldn't be necessary to upload your database. I would not be able to download it anyway.

I suspect that your ProofID field may be numeric. In that case, the DLookup criteria should be formatted as
Expand|Select|Wrap|Line Numbers
  1. ..."ProofID = " & ProofIDComboBox)
The extra quotes are only needed for delimiting string fields.

Also, if you created the prodecure manually, you still need to go to the combo box properties and set the AfterUpdate event to use the code.
Jun 1 '10 #6

P: 8
@ChipR
Hi there, you are so clever. So do I changed the combo box properties, that seems correct, may I just ask one more question?

Are you saying I must do the following:

Price = DLookup("ProofID = " & ProofIDComboBox)

I have tried it nothing happens. I suspect I will have to go do a course for this. I have been struggling with this for months now. It is driving me up the wall.
Jun 1 '10 #7

Expert 100+
P: 1,287
You can find a lot of what you need on Microsoft's reference websites, in this case: DLookup Function (http://office.microsoft.com/en-us/ac...288251033.aspx)
DLookup(expr, domain [, criteria] )
So I was just being lazy, referring to the criteria and not wanting to retype the rest. This function is particularly useful, so check out that page thoroughly and let us know if you still have problems.
Jun 1 '10 #8

P: 8
@ChipR
Thank you for your help. I really appreciate it.

Kind regards
Romes
Jun 1 '10 #9

Post your reply

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