473,401 Members | 2,146 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,401 software developers and data experts.

Open form based on two combo box selection

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 (@@@)

Form 2) all my data :

Year
wk

product 1
product 2 and so on

(@@@) in the OnCLick event procedure of this button I inserted the following code:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Wkly_data_WIP"

stLinkCriteria = "[Year]=" & Me![cboYearSelect] And "[wk]=" & Me![cbowwselect]
DoCmd.OpenForm stDocName, , , stLinkCriteria

But I obtain the "DataTypeMismatch" error:
where is my mistake?

Thanks a lot in advance
Bea
Nov 30 '07 #1
10 3027
puppydogbuddy
1,923 Expert 1GB
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 (@@@)

Form 2) all my data :

Year
wk

product 1
product 2 and so on

(@@@) in the OnCLick event procedure of this button I inserted the following code:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Wkly_data_WIP"

stLinkCriteria = "[Year]=" & Me![cboYearSelect] And "[wk]=" & Me![cbowwselect]
DoCmd.OpenForm stDocName, , , stLinkCriteria

But I obtain the "DataTypeMismatch" error:
where is my mistake?

Thanks a lot in advance
Bea
Try this:
stLinkCriteria = "[Year]= " & Me![cboYearSelect] & " And [wk]= " & Me![cbowwselect]

If it does not work, please provide sample of what the output is supposed to look like.
Nov 30 '07 #2
Try this:
stLinkCriteria = "[Year]= " & Me![cboYearSelect] & " And [wk]= " & Me![cbowwselect]

If it does not work, please provide sample of what the output is supposed to look like.
Hello PuppydogBuddy,

thansk for your reply, but the error persist also with your suggested modification.

I'll try to explain my problem better:
I have a form where I choose the interested period (Year & Wk):
selected these vallue I want to open a second form with all (filtered)
data related to the period (Year & wk).

If I apply the two condition in the linkcriteria separately they work without data type mismatch...

Thanks,
Bea
Nov 30 '07 #3
puppydogbuddy
1,923 Expert 1GB
Hello PuppydogBuddy,

thansk for your reply, but the error persist also with your suggested modification.

I'll try to explain my problem better:
I have a form where I choose the interested period (Year & Wk):
selected these vallue I want to open a second form with all (filtered)
data related to the period (Year & wk).

If I apply the two condition in the linkcriteria separately they work without data type mismatch...

Thanks,
Bea
if year is numeric data type and week is text data type, the syntax would look like as shown below. Additional quotes needed to identify the parameter as a text data type.

Try this:
stLinkCriteria = "[Year]= " & Me![cboYearSelect] & " And [wk]= '" & Me![cbowwselect] & "'"
Nov 30 '07 #4
if year is numeric data type and week is text data type, the syntax would look like as shown below. Additional quotes needed to identify the parameter as a text data type.

Try this:
stLinkCriteria = "[Year]= " & Me![cboYearSelect] & " And [wk]= '" & Me![cbowwselect] & "'"

They are both Integer...I'm lost!!!
;-((((

Bea
Nov 30 '07 #5
puppydogbuddy
1,923 Expert 1GB
They are both Integer...I'm lost!!!
;-((((

Bea
How are year and week displayed? Example 5 or 05? If 05, it is probably text.
Nov 30 '07 #6
How are year and week displayed? Example 5 or 05? If 05, it is probably text.

Wk is displayed as 5 and not as 05...
I've checked in all table/query and the field wk is defined Integer everywhere!

I've changed the Link Criteria in the following way:

stLinkCriteria = "[Year]= " & Val(Me![cboYearSelect]) & " And [wk]= '" & Val(Me![cbowkselect]) & "'"

And now the error message is: "The OpenForm Action was canceled"
I can't understand where is my mistake!

Thanks!
Bea
Dec 3 '07 #7
puppydogbuddy
1,923 Expert 1GB
Wk is displayed as 5 and not as 05...
I've checked in all table/query and the field wk is defined Integer everywhere!

I've changed the Link Criteria in the following way:

stLinkCriteria = "[Year]= " & Val(Me![cboYearSelect]) & " And [wk]= '" & Val(Me![cbowkselect]) & "'"

And now the error message is: "The OpenForm Action was canceled"
I can't understand where is my mistake!

Thanks!
Bea
Bea,
the message is cryptic, so I am not sure. Maybe encountering a null?

if it is just a syntax problem, try it this way:
stLinkCriteria = "[Year]= " & Val(Me![cboYearSelect]) & " And [wk]= " & Val(Me![cbowkselect])
Dec 3 '07 #8
Try this one

stLinkCriteria = "[Year]= " & "&Val(Me![cboYearSelect])&" And "[wk]= " & "&Val(Me![cbowkselect]) &"
Dec 3 '07 #9
sierra7
446 Expert 256MB
Wk is displayed as 5 and not as 05...
I've checked in all table/query and the field wk is defined Integer everywhere!

I've changed the Link Criteria in the following way:

stLinkCriteria = "[Year]= " & Val(Me![cboYearSelect]) & " And [wk]= '" & Val(Me![cbowkselect]) & "'"

And now the error message is: "The OpenForm Action was canceled"
I can't understand where is my mistake!

Thanks!
Bea
A couple of things wrong with the above.
'Year' is a reserved word, it may work but should be avoided
You don't need quotes around the cboWkSelect term which I presume should be an integer

stLinkCriteria = "[Year]= " & Val(Me![cboYearSelect]) & " And [wk]= " & Val(Me![cbowkselect])

If this doesn't work you should consider changing the fieldname 'Year' which I appreciate may have a lot of knock-on consequences.
Dec 3 '07 #10
A couple of things wrong with the above.
'Year' is a reserved word, it may work but should be avoided
You don't need quotes around the cboWkSelect term which I presume should be an integer

stLinkCriteria = "[Year]= " & Val(Me![cboYearSelect]) & " And [wk]= " & Val(Me![cbowkselect])

If this doesn't work you should consider changing the fieldname 'Year' which I appreciate may have a lot of knock-on consequences.

Hi all,

thanks so much for all your help...

I've changed "Year" filed name and used the last suggestion successfully!!!

thanks thanks thansk!!!!
Dec 4 '07 #11

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

Similar topics

2
by: JJ | last post by:
Hi All, When someone selects a value in a select on a form I want to show the same form with another select with certain values depending on first select. How can I do this? Should I keep...
1
by: NBruch | last post by:
Ok let me explain what im trying to do: i need a combo box which needs to be linked to a listbox (or combo box doesnt matter which really) then the listbox should bring up the record in a...
3
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...
3
by: Cagey | last post by:
What I'm trying for: If this selection or if click on selection (highlighted line choice/ which ever selection change) w/in query's combo dropdown list box (on Switchboard), then Open in...
11
blyxx86
by: blyxx86 | last post by:
Alright, I'm trying to create a form that would allow certain documents to be opened by selecting an option within a combo box and then having a single button to open the pertaining file. I know...
2
by: keri | last post by:
Hi everyone, I've started a new topic so as not to get people confused. I apologise for the number of posts i've put on here over the last few days - i really am trying to learn this stuff but...
1
by: KPOJonesECC | last post by:
I am currently working on creating a visual calculator in an access form. The visual bit being a graph and the interactive bit (or what I would like) being that by moving sliders on a series of sub...
1
gcoaster
by: gcoaster | last post by:
Hello, Access is accessing my patience! how does one filter just one form with a single combo box selection? I have a combo box named "cboCallStatus" unbound Row source type = Value...
8
by: Jharp | last post by:
Ok, so im really new to access and programing in general, what i am doing is building a inventory(something simple), the way ive got it set up now is, my entire inventory is in a combo box, and...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.