Value from form as criterium in query?

  • Thread starter Thread starter Henro
  • Start date Start date
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
 
([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
 
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
 
Back
Top