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

OpenForm WhereCondition not working

40
I have been stuck for some time on this now.
I have this code at the moment
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "Form1", , , "Apps= '" & Form!App_Name & "'"
  2.  
Both fields Apps and App_Name are Bound to the same field (text) which is primary key. With the current code I get box where it asks for value of Apps. I have tried changing where condition in different ways, also with me.App_Name but with no result. On some debugs it shows that it finds the right value but it just don't use it! It works fine if I enter the value in the box or write it in hard code: Apps = XXXXX.
I am using Access 2000.
Any ideas what could be the problem?
Oct 5 '07 #1
13 3595
nico5038
3,080 Expert 2GB
Hmm, puzzled why you have two fields bound to the same field.
Normally when this is the case, one field will be named "Apps" and the other e.g. "Text1" as Access won't allow two fields on a form to have the same name.

The popup asking for the "Apps" value is an indication that the field "Apps" isn't found, thus you'll need to check the names of the formcontrols (See the Name property under the "Other" tab of the property window.)

Nic;o)
Oct 5 '07 #2
HyBry
40
Sorry I must have explained it badly.

The button is locates on the form called List1 and has a field called App_Name. So when the button is pressed I want it to open a form called Form1 in which field Apps should display the same value as was in App_Name. They both are bound to the same field in table but they are on different forms.
The names I am using are correct, I have double checked all of them...
Oct 5 '07 #3
Jim Doherty
897 Expert 512MB
Sorry I must have explained it badly.

The button is locates on the form called List1 and has a field called App_Name. So when the button is pressed I want it to open a form called Form1 in which field Apps should display the same value as was in App_Name. They both are bound to the same field in table but they are on different forms.
The names I am using are correct, I have double checked all of them...

Expand|Select|Wrap|Line Numbers
  1.  
  2. DoCmd.OpenForm "Form1", , , "Apps= '" & Me!App_Name & "'"
  3.  
Oct 5 '07 #4
HyBry
40
Expand|Select|Wrap|Line Numbers
  1.  
  2. DoCmd.OpenForm "Form1", , , "Apps= '" & Me!App_Name & "'"
  3.  
Tried that... still asks to enter value for Apps.... tried also with me.App_name. I tried also some with setting Me!App_Name/Form!App_Name as a seperate criteria and debugger showed that it recognizes the value but it was not using it...
Oct 5 '07 #5
Jim Doherty
897 Expert 512MB
Tried that... still asks to enter value for Apps.... tried also with me.App_name. I tried also some with setting Me!App_Name/Form!App_Name as a seperate criteria and debugger showed that it recognizes the value but it was not using it...
Are you sure you are mixing up your table field names and control names here? the Do.cmd.OpenForm command I posted is syntactically correct.

Check that your table field names and Control Names match ie NOT where you have the NAME of a control as Apps on Form1 make sure it is the same as the controlsource and try it again.

When you make a call like that to "Apps" it is expecting 'Apps' to be a field name in the underlying table on which to base its SQL comparison if you do not have a TABLE field called explicitly 'Apps' then this is why is will prompt you because the field doe not exist

Jim
Oct 5 '07 #6
nico5038
3,080 Expert 2GB
Check form1 for the field you assume to be "Apps" by checking the Name property under the "Other" tab of the property window when the "Apps" control is "active" in design mode.

Nic;o)
Oct 5 '07 #7
HyBry
40
OK here is what I have:
List_1 - form which contains text box - App_Name (control source - Interface)
there is also the button with which I want to open form - Form1
On Form1 there is also a text field called Apps (control source - Interface)
So I want after the click to open Form1 where in Apps text box will be the same value as App_Name in List_1 form.
Also I was looking through the code and found some code, which I believe was auto generated and I am not using but seems to be for similar purpose.
Expand|Select|Wrap|Line Numbers
  1. stLinkCriteria = "[To]=" & "'" & Me![App_Name] & "'"
  2.  
Hope this helps
Oct 5 '07 #8
nico5038
3,080 Expert 2GB
OK here is what I have:
List_1 - form which contains text box - App_Name (control source - Interface)
there is also the button with which I want to open form - Form1
On Form1 there is also a text field called Apps (control source - Interface)
So I want after the click to open Form1 where in Apps text box will be the same value as App_Name in List_1 form.
Also I was looking through the code and found some code, which I believe was auto generated and I am not using but seems to be for similar purpose.
Expand|Select|Wrap|Line Numbers
  1. stLinkCriteria = "[To]=" & "'" & Me![App_Name] & "'"
  2.  
Hope this helps
Try this:
1) Open "Form1" in design mode.
2) Single click on the field "Apps"
3) Press Properties button (Hand with white sheet)
4) In properties window under the "Other" tab look into the first propertyline (Name) and tell what's listed there.

Nic;o)
Oct 5 '07 #9
HyBry
40
Good.... got it working sort of... needed to use control source... I did not know that, so now it filters only to selected record.

Thanks Jim and Nico...

But it seems that I need something a bit more complicated then that for my other form.
On the third form I have unbound list box, which has the same control source as previous. And I have a Subform. So how do I filter the subform while still having full list in the list box? alternately could also just make selection in list box.

Thanks again for explaining to use control source and hope you can help o this as well...
Oct 5 '07 #10
nico5038
3,080 Expert 2GB
When you use the wizard to place the subform, it will ask for a linking field. Just accept the proposed field and Access will sync the subform with the keyvalue of the mainform.
When the mainform is filtered, the subform will also be filtered accordingly.

Nic;o)
Oct 5 '07 #11
HyBry
40
That is the thing. I did not use wizard for that... I linked the subform to the listbox on the main form. and the listbox in not bound. Listbox is there purely for selection purpose which then filters the subform. The main form does not even have a Record Source or anything like that...
If that is too complicated or requires me to change a lot... then don't worry.. #Got at least some of it working thanks to you... should be good enough...
Oct 5 '07 #12
nico5038
3,080 Expert 2GB
OK, but here is a link to a sample of the Object/Action principle I use for creating forms and allow the user to select record(s) before applying the action:
http://www.geocities.com/nico5038/xS...tAction-97.zip
for the filtering of the datasheet subform I give my users:
http://www.geocities.com/nico5038/xR...nstruction.zip
perhaps it gives some additional insights.

Nic;o)
Oct 5 '07 #13
HyBry
40
Thanks...
I will have a look at those on Monday... Time for me to finish off the working say
Appreciate you help!!!
Oct 5 '07 #14

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

Similar topics

1
by: Nothing | last post by:
I have a form that the user types in a last name to search for then clicks a search button. Based on the information I want to open the form using the SQL Where statement that will pattern match...
6
by: beowulfs | last post by:
Here's what I've got: I've got a form with combo boxes. you can select already existing company names or type in new ones. if you type in a new one, it prompts you to double click the combo...
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...
4
by: dhowell | last post by:
I have a form with a continuous subform . subform has a combo box called . The following code is opening up the form, but is not applying the "Where" clause which is based on the combo box...
8
by: Mike Charney | last post by:
I am trying to write an Open Form command in VBA with a where clause in it. I need to be able to do two different where clauses: 1) With a between in it: i.e. Between Date1 and Date2 or...
4
by: SDL | last post by:
Help! I have a system that was running fine and I was testing a bottom level form. I went from a menu to a screen where I could enter a phone number or name to find a customer. If the customer...
1
by: kevooo5 | last post by:
I use Access 2003 and I'm having trouble setting the wherecondition for the Openform functions. Usually it would look something like this DoCmd.OpenForm "Contact", , ,wherecondition here I...
3
by: gavm360 | last post by:
Hello, im trying to open a form from an dialog box form: the button on the dialog box has this on the onclick event: DoCmd.OpenForm "frmCASES_UNION", acViewNormal, , "MCH_CASECODE = #" &...
7
by: rik | last post by:
I am trying to build an Access 2002/2003 database application that I would like to offer to other writers so they can track submissions. Just trying to make a helpful tool for writers, poets, or...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
0
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,...

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.