473,471 Members | 1,726 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

pass parameters to form being opened

7 New Member
I am using the following code to click on a field in Activities_Subform to open the Task_Subform with the related records to the particular field in Activities_Subform.

the form opens ok, but only if I put in two parameters (objID and actID), can anyone tell me what the code is to eliminate having to put in the parameters each time.

Private Sub ActivityID_Click()
Dim objID As Integer
Dim actID As Integer

objID = ObjectiveID.Value
actID = ActivityID.Value

DoCmd.OpenForm "Tasks_Subform", , , ""


End Sub
Jun 20 '07 #1
13 2742
JKing
1,206 Recognized Expert Top Contributor
I think all you need to do is add a where statement to your openform command
Give this a try:

Expand|Select|Wrap|Line Numbers
  1. Private Sub ActivityID_Click()
  2. Dim objID As Integer
  3. Dim actID As Integer
  4. Dim strLinkCriteria
  5.  
  6. objID = ObjectiveID.Value
  7. actID = ActivityID.Value
  8. strLinkCriteria = "[objID] = " + objID + " AND [actID] = " + actID
  9.  
  10. DoCmd.OpenForm "Tasks_Subform", , , strLinkCriteria
  11. End Sub
  12.  
Jun 20 '07 #2
lhartmann
7 New Member
Hi

Thanks, I put in that code and I get a runtime error 13 (Type Mismatch)

Any solutions??
Jun 20 '07 #3
JKing
1,206 Recognized Expert Top Contributor
Yes sorry you just need to add "As String" to the line "Dim strLinkCriteria"
That was my mistake sorry about that.
Jun 20 '07 #4
lhartmann
7 New Member
thats ok, but I added As String and I still get the same error and it is referring to this line

strLinkCriteria = "[objID] = " + objID + " AND [actID] = " + actID
Jun 20 '07 #5
JKing
1,206 Recognized Expert Top Contributor
Are objID and actID both number data types? Or are they text?
Jun 20 '07 #6
lhartmann
7 New Member
they are both number types
Jun 20 '07 #7
JKing
1,206 Recognized Expert Top Contributor
Ok try this:

strLinkCriteria = "[objID] = " & objID & " AND [actID] = " & actID
Jun 20 '07 #8
lhartmann
7 New Member
thanks

I do not get the error anymore, but I am still asked to put in the objID and actID parameters, for some reason it is not passing the values
Jun 20 '07 #9
JKing
1,206 Recognized Expert Top Contributor
Is the subform based off a query that has parameters?
Jun 20 '07 #10
JKing
1,206 Recognized Expert Top Contributor
Also check to make sure that any renaming done to tables / queries that the form is based off have been also made on the form. This can cause the form to prompt you for parameters because it is still using a field name that no longer exists in the table /query.
Jun 20 '07 #11
lhartmann
7 New Member
the Task_Subform is based on a query that does have criteria

ObjectiveID criteria is[objID]
ActivityID criteria is [actID]
Jun 20 '07 #12
JKing
1,206 Recognized Expert Top Contributor
If you remove the criteria from the query it will stop the prompt for parameters.

You will need to make another small modification to the strLinkCriteria now. I had previously thought objID and actID were the field names. It's a simple change and should be as follows.

strLinkCriteria = "[ObjectiveID] = " & objID & " AND [ActivityID] = " & actID
Jun 20 '07 #13
lhartmann
7 New Member
Thanks sooooooooo much for your help...... it worked perfectly :>)
Jun 21 '07 #14

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

Similar topics

3
by: DCB | last post by:
Hello. I have an easy question, likely, that has me in a headspin. I have an include file to a frames based site that basically forces frames on the end user if they visit the site and hit a...
3
by: Lyn | last post by:
Hi, I have been experiencing a problem passing a LIKE statement in the WHERE argument of a DoCmd.Openform statement. I have posted that issue separately. However, in an attempt to work around...
7
by: Zlatko Matić | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the...
0
by: Zlatko Matić | last post by:
Hi everybody! Recently I was struggling with client/server issues in MS Access/PostgreSQL combination. Although Access is intuitive and easy to use desktop database solution, many problems...
3
by: Tim | last post by:
Hi, I am trying to pass a SQL Command, complete with parameters and their values from one form to a modal form. The modal form has; public void...
0
by: Helen | last post by:
I have a simple oledb dataset on one windows form in vb .net 2002 calling one column from oracle 7, results appear in a text box But, only the first results appears. Goal is to show all results...
6
by: DMUM via AccessMonster.com | last post by:
Hello I am trying to pass the name of my subform to a function/sub but I can't seem to get it to work. I am using an autokey function (ctrl E) to unlock text boxes on a subform. I have a few...
24
by: =?Utf-8?B?U3dhcHB5?= | last post by:
Can anyone suggest me to pass more parameters other than two parameter for events like the following? Event: Onbutton_click(object sender, EventArgs e)" Event handler: button.Click += new...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
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
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
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
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...
1
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
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...
0
muto222
php
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.