473,657 Members | 2,572 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Open form based on querie with parameters

759 Contributor
I have some global variables.
I use this variables to open a form based on a query with parameters.

Now I use the On Load event to prepare an SQL string which include values of the global variables then: FORM.RecordSour ce = SQL .
Works fine but, if I wish to make changes is a hard work.

The question is: Is here any way to pass values directly to the RecordSource query ?

The same question for a ListBos RowSource.

The link criteria using with DoCmd.OpenForm is not an option.

Thank you !
Apr 14 '11 #1
3 4519
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
The question is at what TIME or tied to what EVENT do you wish to change the forms recordsource? It can be done at runtime, and not only in the LOAD event.

Same goes for combobox and listbox, with 1 small difference. While changing a forms recordsource, will trigger a requery automatically, it must be done manually (in code) for listbox and combobox.
Apr 14 '11 #2
Mihail
759 Contributor
The form must be updated:

1) When I open it, exactly as I use this code:
Expand|Select|Wrap|Line Numbers
  1.     stLinkCriteria = "[Cod]=" & Me![Cod]
  2.     DoCmd.OpenForm "FormToOpen", , , stLinkCriteria
But there are more variables (not only "Cod"), this variables are GLOBAL and, for some reasons, I can't use stLinkCriteria. Is too hard for my english to explain why.

2) At run time when is necessary (one of the global variables is change)

The ListBox must be populate when the containing form is open and at run time.

In both cases I like to define the .RecordSource (or .RowSource) at design time, using parametric queries, and, at run time, to pass values to this parameters (using VBA, of course, not manually in the InputBox) and requery.

Can be done ? How ?
The code example is great.

Thank you
Apr 15 '11 #3
Mihail
759 Contributor
This is an example how I work now:

lstApartamenteC ontorizate.RowS ource = _
"SELECT Apartamente.Cod , Apartamente.Apa rtament " & _
"FROM Apartament_situ atie INNER JOIN Apartamente ON Apartament_situ atie.Cod = Apartamente.Cod _Sit " & _
"WHERE (((Apartamente. Cod_Nod) = " & curCod_Nod & ") And ((Apartamente.C od_Sit) = 1)) " & _
"ORDER BY Apartamente.Apa rtament;"


lstApartamenteC ontorizate is a ListBox.

If the global variable curCod_Nod is change, then I rerun this code. Works, as I say, ok. But, if I wish to change all SQL, is a work for an old chinese.
Apr 15 '11 #4

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

Similar topics

3
2817
by: Rosy | last post by:
Hello all. I think my request is a simple one; however, I am unable to figure it out by myself. I need a form (frmCargoEntry) to open whenever the cargo dept is chosen on another field. So when DeptId is equal to 1 then fromCargoEntry should open on top of the current form for data entry. Can someone help me with the correct phrasing? My main form is frmNewJobs. Thanks. Karen
1
5309
by: starke1120 | last post by:
Is there a way to open a form based on query type.. Example.. If a certain query result is 1 then open the form to this result.. If the query results are NULL or 0 results, then open open for in add or add new record form. The query will return one to 0 records so this is my option. Im guessing the form load event would be the place but not sure how to go about it.
6
3529
by: Markus_989 | last post by:
I have a LOANS table that has a list of loan details for different borrowers. I have a main switchboard with a LOANSELECT combo box (that displays a list of borrower last names and loan numbers). I'd like to be able to have a user click on the say, RECEIVE PAYMENT button that will open the payments form. This form should open to the loan that was selected from the LOANSELECT box. This form also has a box on it to switch to different...
2
2952
by: ssoman | last post by:
I was asked if I could open one of two possible data entry forms based on what is chosen in a drop down list. For example, if Teacher A is chosen from a list, then data entry form X opens. However, if Teacher B is chosen from the list, then data entry form Y is opened. Any thoughts? Thanks much Sheldon Soman
1
2327
by: Kevin | last post by:
The menu form has two options, one to create a new estimate, the second to open an existing estimate. Under option two is a list box containing all of the estimates. There are several different estimate categories however. The siginificance is, all of the estimates are in the same table, but there are different forms for viewing and editing each type. Each estimate record has a field for EstimateType. The user selects an estimate from...
10
3046
by: Beatrice | last post by:
I need to open a form selecting all data from a previous form i.e: Form 1) combo box 1 named "cboYearSelect" displayed as "Year" based on qry QryYearList ( only one field "Year") combo box 2 named "cbowwselect" displayed as "wk" based on qry Qry WkList (field: Year, wk) displaying only wk field. OPEN FORM (2) BUTTON (@@@)
2
2676
by: ghetto_banjo | last post by:
Ok, i thought i had this one figured out, apparently not. Here is my code on my button click event: stDocName = "frmInvoice" stLinkCriteria = "=" & Me! DoCmd.OpenForm stDocName, , , stLinkCriteria List13 is a single column list box of invoice numbers. When I choose
11
11937
by: rakabuku | last post by:
I have this form called "switchboard" and in it are two combo boxes: Organization and Staff Initials (cboOrganization, cboStaff_init). There is also a search button called "OK". See picture "DB1" What I want to do is, based on the selection of my "Staff Initials" combo box, when I click the "OK" button, I want the Multiple Items Form (Test 2) to open that correspond only to that "Staff Initials". See Picture DB2 and DB 1. I'm really new at...
1
1704
by: Sharkiness | last post by:
My main Person Form has a button to add accounts. This opens the accounts form in Edit Mode. It is a continuous form. I have setup my relationships but when The account form opens I would like the PersonID to be automatically populated in the first blank record so that I can add an account, I would also like the next new account to add the same PersonID in the same way that that a Subform would do it. Can anyone help with this? Thanks
0
8326
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8743
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8522
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8622
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7355
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5647
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2745
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 we have to send another system
2
1973
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.