Value from form as criterium in query?

H

Henro

I have a form (Start MIS) with two unbound fields. Can the value's in these
fields be used as criteria in query's? If so, how can I do so? It is a field
StartDate (Date/Time) in which I want to use the query's.

Relevant code:
([Begindatum]-1) And <([Einddatum]+1)

works as criterium
([Formulieren]![MIS starten]![MISstart]-1) And <([Formulieren]![MIS
starten]![MISeind ]+1)

does not work.

This is the code that starts the query, fired by clicking the button
'Genereren'

Private Sub Genereren_Click()
DoCmd.DeleteObject acTable, "MIS"
DoCmd.OpenQuery "Maak MIS"
End Sub

How can the fields [Mis starten].[MISstart] en [MIS starten].[MISeind] be
used as criteria in the query [Maak MIS]???

Thnx for thinking!

Henro
 
W

Wayne Morgan

([Formulieren]![MIS starten]![MISstart]-1) And <([Formulieren]![MIS
starten]![MISeind ]+1)

I don't speak your language, but judging from what I see here, the basic
syntax is correct. Sometimes if the value is text or a date you need to put
delimiters around the values. Try
(#[Formulieren]![MIS starten]![MISstart]#-1) And
<(#[Formulieren]![MISstarten]![MISeind ]#+1)

Also, the form has to be open at the time you call for the data from it.
Another thing that comes to mind is that in some cases Access requires the
data to be in US format. If that is the case (I don't think it is here), you
will need to format the data. You may also need to format the field so that
they match.
(Format([Formulieren]![MIS starten]![MISstart], "mm/dd/yyyy")-1) And
<(Format([Formulieren]![MISstarten]![MISeind ], "mm/dd/yyyy")+1)


--
Wayne Morgan
Microsoft Access MVP


Henro said:
I have a form (Start MIS) with two unbound fields. Can the value's in these
fields be used as criteria in query's? If so, how can I do so? It is a field
StartDate (Date/Time) in which I want to use the query's.

Relevant code:
([Begindatum]-1) And <([Einddatum]+1)

works as criterium
([Formulieren]![MIS starten]![MISstart]-1) And <([Formulieren]![MIS
starten]![MISeind ]+1)

does not work.

This is the code that starts the query, fired by clicking the button
'Genereren'

Private Sub Genereren_Click()
DoCmd.DeleteObject acTable, "MIS"
DoCmd.OpenQuery "Maak MIS"
End Sub

How can the fields [Mis starten].[MISstart] en [MIS starten].[MISeind] be
used as criteria in the query [Maak MIS]???

Thnx for thinking!

Henro
 
H

Henro

I succeeded in declaring them as global variables.
Something probably very simple to most of you but three weeks ago I wouldn't
dare dream of doing this all by myself :p

Thanx all for your support!

Grtz Henro


Wayne Morgan said:
([Formulieren]![MIS starten]![MISstart]-1) And <([Formulieren]![MIS
starten]![MISeind ]+1)

I don't speak your language, but judging from what I see here, the basic
syntax is correct. Sometimes if the value is text or a date you need to put
delimiters around the values. Try
(#[Formulieren]![MIS starten]![MISstart]#-1) And
<(#[Formulieren]![MISstarten]![MISeind ]#+1)

Also, the form has to be open at the time you call for the data from it.
Another thing that comes to mind is that in some cases Access requires the
data to be in US format. If that is the case (I don't think it is here), you
will need to format the data. You may also need to format the field so that
they match.
(Format([Formulieren]![MIS starten]![MISstart], "mm/dd/yyyy")-1) And
<(Format([Formulieren]![MISstarten]![MISeind ], "mm/dd/yyyy")+1)


--
Wayne Morgan
Microsoft Access MVP


Henro said:
I have a form (Start MIS) with two unbound fields. Can the value's in these
fields be used as criteria in query's? If so, how can I do so? It is a field
StartDate (Date/Time) in which I want to use the query's.

Relevant code:
([Begindatum]-1) And <([Einddatum]+1)

works as criterium
([Formulieren]![MIS starten]![MISstart]-1) And <([Formulieren]![MIS
starten]![MISeind ]+1)

does not work.

This is the code that starts the query, fired by clicking the button
'Genereren'

Private Sub Genereren_Click()
DoCmd.DeleteObject acTable, "MIS"
DoCmd.OpenQuery "Maak MIS"
End Sub

How can the fields [Mis starten].[MISstart] en [MIS starten].[MISeind] be
used as criteria in the query [Maak MIS]???

Thnx for thinking!

Henro
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top