URGENT PLease!!!! Run-Time error: 103 Type Mismatch

G

Guest

Hi everyone,
Access 2003, Windows XP

I have a form to open a form filtered by range date and city name text with
the following onclick command button procedure :


Private Sub Comando6_Click()
Dim strWhere As String 'condição
Dim strForm As String
Dim strLocalidade As String
Dim strData As String
Const conDateFormat = "\#mm\/dd\/yyyy\#"

strForm = "Consulta_por_localidade"
strLocalidade = "LOCALIDADE"
strData = "ENTR_DIA_AGENDADO"

strWhere = ("localidade = '" & Me!LOCALIDADE & "'") And (strData & " Between
" & Format(Me.txtstartdate, conDateFormat) _
& " And " & Format(Me.txtenddate, conDateFormat))
DoCmd.OpenForm strForm, , , strWhere

End Sub
 
G

Guest

Could it be your date format:

Const conDateFormat = "\#mm\/dd\/yyyy\#"

Should it be: "mm/dd/yyyy"?
 
G

Guest

Hi srbond,
thanks for the help, but indeed it didn't help... :(

If I try the first condition:

strWhere = ("localidade = '" & Me!LOCALIDADE & "'")
it works just fine

If I try the second one:

strWhere = (strData & " Between " & Format(Me.txtstartdate, conDateFormat) _
& " And " & Format(Me.txtenddate, conDateFormat))
it also works just as expected.

The problem is when I make strWhere= (1st condition) and (2nd condition)

I'm getting desesperated :(


--
Thanks,

Emanuel Violante Galeano


"srbond" escreveu:
 
R

RoyVidar

Emanuel Violante said:
Hi everyone,
Access 2003, Windows XP

I have a form to open a form filtered by range date and city name
text with the following onclick command button procedure :


Private Sub Comando6_Click()
Dim strWhere As String 'condição
Dim strForm As String
Dim strLocalidade As String
Dim strData As String
Const conDateFormat = "\#mm\/dd\/yyyy\#"

strForm = "Consulta_por_localidade"
strLocalidade = "LOCALIDADE"
strData = "ENTR_DIA_AGENDADO"

strWhere = ("localidade = '" & Me!LOCALIDADE & "'") And (strData & "
Between " & Format(Me.txtstartdate, conDateFormat) _
& " And " & Format(Me.txtenddate, conDateFormat))
DoCmd.OpenForm strForm, , , strWhere

End Sub

Try something like this

strWhere = "localidade = '" & Me!LOCALIDADE & "' And " & strData & _
" Between " & Format(Me.txtstartdate, conDateFormat) & _
" And " & Format(Me.txtenddate, conDateFormat))
 
R

RoyVidar

RoyVidar said:
Try something like this

strWhere = "localidade = '" & Me!LOCALIDADE & "' And " & strData & _
" Between " & Format(Me.txtstartdate, conDateFormat) & _
" And " & Format(Me.txtenddate, conDateFormat))

Argh... at least one typo - remove the last parens in the last line,
sorry

" And " & Format(Me.txtenddate, conDateFormat)
 
G

Guest

Many thanks Roy,

Thanks to you I finally solved my problem :D

--
Thanks,

Emanuel Violante Galeano


"RoyVidar" escreveu:
 

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