473,395 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

INDIRECT command in excel quivalent in Access

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.

8 6222
ChipR
1,287 Expert 1GB
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
romes
8
Thank you so much. I am going to try it.

Kind regards
May 31 '10 #3
romes
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
romes
8
@ChipR
Hi, is there some way I can upload the file?
May 31 '10 #5
ChipR
1,287 Expert 1GB
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
romes
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
ChipR
1,287 Expert 1GB
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
romes
8
@ChipR
Thank you for your help. I really appreciate it.

Kind regards
Romes
Jun 1 '10 #9

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

Similar topics

3
by: Jim Wyse | last post by:
I'm trying to use VB.NET to control Excel and Access, but finding it very slow going. I've just downloaded an Excel sample project from...
2
by: Danielle | last post by:
I have a database of address that are downloaded from the internet to excel. I have imported the data to access to create mail-outs easily, however, it is necessary for me to keep the excel...
3
by: Santa-D | last post by:
I've got an excel sheet that I need to import into a table, however, I want the function to automatically manipulate the data prior to it being imported. For example, i have a field called and...
2
by: ontherun | last post by:
Hi, Could anyone please assist me on how to import Excel records to Access. the records in excel are not in the same order as that of the one in Access. there are about 1000 records needs to be...
3
by: oli insight | last post by:
I have an excel spreadsheet with 500 rows of information. I want to copy and paste that information into an access table that i'm using, column by column.... But access only lets me copy and paste...
3
by: ofilha | last post by:
I need to format a column in excel but would like to do it from Access using VB. I have hacked around and found a few ways to get to the workbook but have a problem getting to the sheet i want. But,...
3
by: MarcGA | last post by:
(Excel 2003, Access 2003, XP, novice user here) I can't get Access to accept multiple Excel files to the same table. I can import the spreadsheets to a new table, but I need to import 23...
16
by: Phil Stanton | last post by:
I have a form with a button which is supposed to open an Excel file (With lots of Macros /VBA) in it. The Excel file gets it's data from the Access program Here is the code Private Sub...
4
by: mld01s | last post by:
Hi all!! I need help, I have been stuck for a few days on this one. I am trying to open an excel table from a command button in Access. The excel table has an auto_open macro, that is supposed to...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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
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
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...

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.