473,379 Members | 1,344 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,379 software developers and data experts.

passing parameter in Form

Hi All,

I'm changing my DB view, in order to facilitate the data access.

My problem is the following:
I have different page that allow me to view different data, organized in different way, concerning different products

In the form A I want to click on "Product X Button"
that open the Form B in which I choose the kind of data I need (maybe product info, product volume and so on) so clicking on right button the relative form C (or D or E, depends on button ) opens with data concerning the product X ( chosen in Form A).

How can I open the the Form C (D, E,...) concerning ProductX, without creating dedicated form for each product??

Thanks in advance,
Bea
May 22 '08 #1
4 2094
Stewart Ross
2,545 Expert Mod 2GB
Hi Bea. When you want to view a specific record in a form you open the form using a Where condition as a filter to restrict the form to one matching record.

When the command button you mention is clicked you would have some selection code in your on click event that chooses the right form name, then open the form using a filter like the skeleton below, substituting for the names of controls etc you really use:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm FormName, acNormal,, "[ProductCodeField] = '" & Me.ComboOrListboxForSelection & "'"
I have assumed that the product code would be the matching field for filtering, and that it is a string. If it is a number you would not need the single quotes on either side of the combo reference.

-Stewart
May 22 '08 #2
Hi Stewart,

the problem is that in FOrm B I have only btton opening form, not related to Query, so I cannot use "Me.ComboOrListboxForSelection " command.

My idea was, but I don't know if it is possible, to pass the parameter in VBA:

Private Sub Command1_Click(Parameter|Filter)

Do you think is it possible???

Thanks,
Bea






Hi Bea. When you want to view a specific record in a form you open the form using a Where condition as a filter to restrict the form to one matching record.

When the command button you mention is clicked you would have some selection code in your on click event that chooses the right form name, then open the form using a filter like the skeleton below, substituting for the names of controls etc you really use:

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm FormName, acNormal,, "[ProductCodeField] = '" & Me.ComboOrListboxForSelection & "'"
I have assumed that the product code would be the matching field for filtering, and that it is a string. If it is a number you would not need the single quotes on either side of the combo reference.

-Stewart
May 23 '08 #3
Stewart Ross
2,545 Expert Mod 2GB
Hi Bea. It would be easier to pass the value as an argument to the form using the OpenArgs property of the form. You can pass the form a string value in the DoCmd.OpenForm sequence, and retrieve it within the form itself (using the On Form Load event to do so).

You can also refer directly to a control value in another form. If Form A (say) is still open you can always refer to a combo on it from another form, using the full control reference. There are several alternative ways to do so, all of which allow you to access values in another form. The examples below would set a local variable in your VBA code to the value of such a control:
Expand|Select|Wrap|Line Numbers
  1. SomeLocalVariable = forms!formname!controlname
  2. SomeLocalVariable = forms("formname").controls("controlname")
  3. SomeLocalVariable = forms("formname")!controlname
Whilst I offer these as ways forward you may wish to try, I can't help but feel that the multi-form approach you are trying is not quite right if you are having to bend things this way. You could use a different approach by adding a Tab control in your master form, which provides a set of tabbed pages that would allow you to show a product view filtered as necessary all from within the one main form.

I attach an example screenshot showing a part of one of my own tabbed pagesets.

-Stewart
Attached Images
File Type: jpg ScreenHunter_34.jpg (16.0 KB, 155 views)
May 23 '08 #4
Hi Stewart,

the big problem on this DB it due that it's the first!and I've learnt Access (And VBA) working on it.... so more advanced Form/Query must cohabit with basic ones (that are the first I created... and on which the DB is based).

I've never tried the Tab option... I'll study it and introduce it in my DB.

I'll keep you informed about my improvements! :-)

Bea
May 23 '08 #5

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

Similar topics

2
by: zlatko | last post by:
There is a form in an Access Project (.adp, Access front end with SQL Server) for entering data into a table for temporary storing. Then, by clicking a botton, several action stored procedures...
4
by: Ron Rohrssen | last post by:
I want to show a dialog and when the form (dialog) is closed, return to the calling form. The calling form should then be able to pass the child form to another object with the form as a...
1
by: Maria | last post by:
Hello! I am new to Crystal reports an I have problems passing parameters form outside to Crystal report an creating a report with data from more than one table This is the problem: I have to...
3
by: Mark | last post by:
Hi From what I understand, you can pass arrays from classic ASP to .NET using interop, but you have to change the type of the.NET parameter to object. This seems to be because classic ASP passes...
2
by: Thomas Beyerlein | last post by:
Hello, I am trying to build a UI and I need the user to go though about 4 forms making decisions and then passing the decision to the next form. Finally on the last form I need all the answers to...
13
by: Deano | last post by:
Apparently you can only do this with one value i.e Call MyAssetLocationZoom(Me!txtLocation, "Amend data") This runs; Public Sub MyAssetLocationZoom(ctl As Control, formName As String) On...
3
by: Ross McLean | last post by:
Hi all, I've been teaching myself C# for a new project at work. I have a bit of a background in c++ and java but never been what you could call a guru. I'm having some strange things happening...
4
by: Ranginald | last post by:
Hi, I'm having trouble passing a parameter from my default.aspx page to my default2.aspx page. I have values from a query in a list box and the goal is to pass the "catID" from default.aspx...
2
by: Nab | last post by:
I have just tried to pass parameters to a procedure in VB 2005 and realised that you only need to pass the input parameter. The output parameter's value will be returned without the need to pass it...
1
by: tarunkhatri | last post by:
Hi, I want to pass the parameter of employee_id to a page. My code is working fine and passing parameter to page but the problem is rather then the current parameter. It passed the parameter which...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.