I need help with the syntax of a OR statement...

  • Thread starter Thread starter Kelvin Beaton
  • Start date Start date
K

Kelvin Beaton

I'm trying to check for two things here.
One that there's an import date, that part work.
Two I want to make sure the date entered is greater then the date entered.
But it doesn't like the ">" greater then sign.
I've tried this,
[Query]![qry_PSI_ImportDate_Max]![ImportDate]
and this
(>[Query]![qry_PSI_ImportDate_Max]![ImportDate])
and this
([Query]![qry_PSI_ImportDate_Max]![ImportDate])

with no luck.


This code works fine without the OR statement.
----------------------------
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String
If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
Else
----------------------------

How do I get it to look for greater than?

Can someone point me in the right direction?

What am I doing wrong?

Thanks

Kelvin
 
Hi,
you can not reference query that why, instead you have to use some function:

If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
Elseif [ImportDate] > dmax("ImportDate","qry_PSI_ImportDate_Max") then
msgbox "bla-bla"
end if


--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


Kelvin Beaton said:
I'm trying to check for two things here.
One that there's an import date, that part work.
Two I want to make sure the date entered is greater then the date entered.
But it doesn't like the ">" greater then sign.
I've tried this,
[Query]![qry_PSI_ImportDate_Max]![ImportDate]
and this
(>[Query]![qry_PSI_ImportDate_Max]![ImportDate])
and this
([Query]![qry_PSI_ImportDate_Max]![ImportDate])

with no luck.


This code works fine without the OR statement.
----------------------------
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String
If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
Else
----------------------------

How do I get it to look for greater than?

Can someone point me in the right direction?

What am I doing wrong?

Thanks

Kelvin
 
Hi Alex

it seems that no matter what date I put in the message "You have already
imported PSI data for this date" pops up.
I've tried dates before and after...

Below is the complete code.
If both of the first conditions are met, I want it to run the code after the
Else statement.

Can you see what's causing this?

Thanks

Kelvin

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String

If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
ElseIf [ImportDate] > DMax([ImportDate], "qry_PSI_ImportDate_Max")
Then
MsgBox "You have already imported PSI data for this date"
Else
DoCmd.RunMacro "mac_UpdateMCCSACleanedTable", , ""
DoCmd.OpenQuery "qry_PSI1_DataCleaner", acViewNormal, acEdit
DoCmd.OpenQuery "qry_PSI2_Append_ClientRecords", acViewNormal,
acEdit
DoCmd.SetWarnings False
DoCmd.OpenQuery "qry_PSI3_MakeTable_ContactLog", acViewNormal,
acEdit
DoCmd.OpenQuery "qry_PSI4_Append_ContactLog", acViewNormal, acEdit
DoCmd.RunMacro "mac_UpdateMCCSACleanedTable", , ""
MsgBox "PSI Data Imported Successfully."
DoCmd.Close
Exit_Command8_Click:
Exit Sub

Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click

End If
End Sub
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


Alex Dybenko said:
Hi,
you can not reference query that why, instead you have to use some
function:

If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
Elseif [ImportDate] > dmax("ImportDate","qry_PSI_ImportDate_Max") then
msgbox "bla-bla"
end if


--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


Kelvin Beaton said:
I'm trying to check for two things here.
One that there's an import date, that part work.
Two I want to make sure the date entered is greater then the date
entered.
But it doesn't like the ">" greater then sign.
I've tried this,
[Query]![qry_PSI_ImportDate_Max]![ImportDate]
and this
(>[Query]![qry_PSI_ImportDate_Max]![ImportDate])
and this
([Query]![qry_PSI_ImportDate_Max]![ImportDate])

with no luck.


This code works fine without the OR statement.
----------------------------
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String
If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
Else
----------------------------

How do I get it to look for greater than?

Can someone point me in the right direction?

What am I doing wrong?

Thanks

Kelvin
 
I noticed that I had deleted all the records that had an Import date, so the
"qry_PSI_ImportDate_Max" was returning nothing, so I added a date to an
existing record, now the query "qry_PSI_ImportDate_Max" returns that date...

I guess I'm still stuck

Alex Dybenko said:
Hi,
you can not reference query that why, instead you have to use some
function:

If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
Elseif [ImportDate] > dmax("ImportDate","qry_PSI_ImportDate_Max") then
msgbox "bla-bla"
end if


--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


Kelvin Beaton said:
I'm trying to check for two things here.
One that there's an import date, that part work.
Two I want to make sure the date entered is greater then the date
entered.
But it doesn't like the ">" greater then sign.
I've tried this,
[Query]![qry_PSI_ImportDate_Max]![ImportDate]
and this
(>[Query]![qry_PSI_ImportDate_Max]![ImportDate])
and this
([Query]![qry_PSI_ImportDate_Max]![ImportDate])

with no luck.


This code works fine without the OR statement.
----------------------------
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String
If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
Else
----------------------------

How do I get it to look for greater than?

Can someone point me in the right direction?

What am I doing wrong?

Thanks

Kelvin
 
Hi,
put a stop at that line:

ElseIf [ImportDate] > DMax([ImportDate], "qry_PSI_ImportDate_Max")


then go to debug window ctrl+G and type there:
?[ImportDate]

?DMax([ImportDate], "qry_PSI_ImportDate_Max")

you will see the actual values and this will give you an idea what is going
wrong

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


Kelvin Beaton said:
Hi Alex

it seems that no matter what date I put in the message "You have already
imported PSI data for this date" pops up.
I've tried dates before and after...

Below is the complete code.
If both of the first conditions are met, I want it to run the code after
the Else statement.

Can you see what's causing this?

Thanks

Kelvin

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String

If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
ElseIf [ImportDate] > DMax([ImportDate], "qry_PSI_ImportDate_Max")
Then
MsgBox "You have already imported PSI data for this date"
Else
DoCmd.RunMacro "mac_UpdateMCCSACleanedTable", , ""
DoCmd.OpenQuery "qry_PSI1_DataCleaner", acViewNormal, acEdit
DoCmd.OpenQuery "qry_PSI2_Append_ClientRecords", acViewNormal,
acEdit
DoCmd.SetWarnings False
DoCmd.OpenQuery "qry_PSI3_MakeTable_ContactLog", acViewNormal,
acEdit
DoCmd.OpenQuery "qry_PSI4_Append_ContactLog", acViewNormal, acEdit
DoCmd.RunMacro "mac_UpdateMCCSACleanedTable", , ""
MsgBox "PSI Data Imported Successfully."
DoCmd.Close
Exit_Command8_Click:
Exit Sub

Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click

End If
End Sub
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


Alex Dybenko said:
Hi,
you can not reference query that why, instead you have to use some
function:

If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
Elseif [ImportDate] > dmax("ImportDate","qry_PSI_ImportDate_Max") then
msgbox "bla-bla"
end if


--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


Kelvin Beaton said:
I'm trying to check for two things here.
One that there's an import date, that part work.
Two I want to make sure the date entered is greater then the date
entered.
But it doesn't like the ">" greater then sign.
I've tried this,
[Query]![qry_PSI_ImportDate_Max]![ImportDate]
and this
(>[Query]![qry_PSI_ImportDate_Max]![ImportDate])
and this
([Query]![qry_PSI_ImportDate_Max]![ImportDate])

with no luck.


This code works fine without the OR statement.
----------------------------
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String
If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
Else
----------------------------

How do I get it to look for greater than?

Can someone point me in the right direction?

What am I doing wrong?

Thanks

Kelvin
 
Hi Alex

Thanks for the reply

Turns out it needed quotes around "[ImportDate]"

Thanks

Kelvin


Alex Dybenko said:
Hi,
put a stop at that line:

ElseIf [ImportDate] > DMax([ImportDate], "qry_PSI_ImportDate_Max")


then go to debug window ctrl+G and type there:
?[ImportDate]

?DMax([ImportDate], "qry_PSI_ImportDate_Max")

you will see the actual values and this will give you an idea what is
going wrong

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


Kelvin Beaton said:
Hi Alex

it seems that no matter what date I put in the message "You have already
imported PSI data for this date" pops up.
I've tried dates before and after...

Below is the complete code.
If both of the first conditions are met, I want it to run the code after
the Else statement.

Can you see what's causing this?

Thanks

Kelvin

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String

If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
ElseIf [ImportDate] > DMax([ImportDate], "qry_PSI_ImportDate_Max")
Then
MsgBox "You have already imported PSI data for this date"
Else
DoCmd.RunMacro "mac_UpdateMCCSACleanedTable", , ""
DoCmd.OpenQuery "qry_PSI1_DataCleaner", acViewNormal, acEdit
DoCmd.OpenQuery "qry_PSI2_Append_ClientRecords", acViewNormal,
acEdit
DoCmd.SetWarnings False
DoCmd.OpenQuery "qry_PSI3_MakeTable_ContactLog", acViewNormal,
acEdit
DoCmd.OpenQuery "qry_PSI4_Append_ContactLog", acViewNormal, acEdit
DoCmd.RunMacro "mac_UpdateMCCSACleanedTable", , ""
MsgBox "PSI Data Imported Successfully."
DoCmd.Close
Exit_Command8_Click:
Exit Sub

Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click

End If
End Sub
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


Alex Dybenko said:
Hi,
you can not reference query that why, instead you have to use some
function:

If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
Elseif [ImportDate] > dmax("ImportDate","qry_PSI_ImportDate_Max")
then
msgbox "bla-bla"
end if


--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


"Kelvin Beaton" <kelvin at mccsa dot com> wrote in message
I'm trying to check for two things here.
One that there's an import date, that part work.
Two I want to make sure the date entered is greater then the date
entered.
But it doesn't like the ">" greater then sign.
I've tried this,
[Query]![qry_PSI_ImportDate_Max]![ImportDate]
and this
(>[Query]![qry_PSI_ImportDate_Max]![ImportDate])
and this
([Query]![qry_PSI_ImportDate_Max]![ImportDate])

with no luck.


This code works fine without the OR statement.
----------------------------
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String
If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
Else
----------------------------

How do I get it to look for greater than?

Can someone point me in the right direction?

What am I doing wrong?

Thanks

Kelvin
 
oops, sorry, this was a typo

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

Kelvin Beaton said:
Hi Alex

Thanks for the reply

Turns out it needed quotes around "[ImportDate]"

Thanks

Kelvin


Alex Dybenko said:
Hi,
put a stop at that line:

ElseIf [ImportDate] > DMax([ImportDate], "qry_PSI_ImportDate_Max")


then go to debug window ctrl+G and type there:
?[ImportDate]

?DMax([ImportDate], "qry_PSI_ImportDate_Max")

you will see the actual values and this will give you an idea what is
going wrong

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


Kelvin Beaton said:
Hi Alex

it seems that no matter what date I put in the message "You have already
imported PSI data for this date" pops up.
I've tried dates before and after...

Below is the complete code.
If both of the first conditions are met, I want it to run the code after
the Else statement.

Can you see what's causing this?

Thanks

Kelvin

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String

If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
ElseIf [ImportDate] > DMax([ImportDate], "qry_PSI_ImportDate_Max")
Then
MsgBox "You have already imported PSI data for this date"
Else
DoCmd.RunMacro "mac_UpdateMCCSACleanedTable", , ""
DoCmd.OpenQuery "qry_PSI1_DataCleaner", acViewNormal, acEdit
DoCmd.OpenQuery "qry_PSI2_Append_ClientRecords", acViewNormal,
acEdit
DoCmd.SetWarnings False
DoCmd.OpenQuery "qry_PSI3_MakeTable_ContactLog", acViewNormal,
acEdit
DoCmd.OpenQuery "qry_PSI4_Append_ContactLog", acViewNormal,
acEdit
DoCmd.RunMacro "mac_UpdateMCCSACleanedTable", , ""
MsgBox "PSI Data Imported Successfully."
DoCmd.Close
Exit_Command8_Click:
Exit Sub

Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click

End If
End Sub
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


Hi,
you can not reference query that why, instead you have to use some
function:

If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
Elseif [ImportDate] > dmax("ImportDate","qry_PSI_ImportDate_Max")
then
msgbox "bla-bla"
end if


--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


"Kelvin Beaton" <kelvin at mccsa dot com> wrote in message
I'm trying to check for two things here.
One that there's an import date, that part work.
Two I want to make sure the date entered is greater then the date
entered.
But it doesn't like the ">" greater then sign.
I've tried this,
[Query]![qry_PSI_ImportDate_Max]![ImportDate]
and this
(>[Query]![qry_PSI_ImportDate_Max]![ImportDate])
and this
([Query]![qry_PSI_ImportDate_Max]![ImportDate])

with no luck.


This code works fine without the OR statement.
----------------------------
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String
If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
Else
----------------------------

How do I get it to look for greater than?

Can someone point me in the right direction?

What am I doing wrong?

Thanks

Kelvin
 
Hi Alex

do you know if this course is any good?
http://www.youlearn.com/products/lk-products/A/access2003dev/access2003dev.html
Do you know of any better sources for these topics?

Thanks

Kelvin


Alex Dybenko said:
oops, sorry, this was a typo

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

Kelvin Beaton said:
Hi Alex

Thanks for the reply

Turns out it needed quotes around "[ImportDate]"

Thanks

Kelvin


Alex Dybenko said:
Hi,
put a stop at that line:

ElseIf [ImportDate] > DMax([ImportDate], "qry_PSI_ImportDate_Max")


then go to debug window ctrl+G and type there:
?[ImportDate]

?DMax([ImportDate], "qry_PSI_ImportDate_Max")

you will see the actual values and this will give you an idea what is
going wrong

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


"Kelvin Beaton" <kelvin at mccsa dot com> wrote in message
Hi Alex

it seems that no matter what date I put in the message "You have
already imported PSI data for this date" pops up.
I've tried dates before and after...

Below is the complete code.
If both of the first conditions are met, I want it to run the code
after the Else statement.

Can you see what's causing this?

Thanks

Kelvin

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String

If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
ElseIf [ImportDate] > DMax([ImportDate], "qry_PSI_ImportDate_Max")
Then
MsgBox "You have already imported PSI data for this date"
Else
DoCmd.RunMacro "mac_UpdateMCCSACleanedTable", , ""
DoCmd.OpenQuery "qry_PSI1_DataCleaner", acViewNormal, acEdit
DoCmd.OpenQuery "qry_PSI2_Append_ClientRecords", acViewNormal,
acEdit
DoCmd.SetWarnings False
DoCmd.OpenQuery "qry_PSI3_MakeTable_ContactLog", acViewNormal,
acEdit
DoCmd.OpenQuery "qry_PSI4_Append_ContactLog", acViewNormal,
acEdit
DoCmd.RunMacro "mac_UpdateMCCSACleanedTable", , ""
MsgBox "PSI Data Imported Successfully."
DoCmd.Close
Exit_Command8_Click:
Exit Sub

Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click

End If
End Sub
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


Hi,
you can not reference query that why, instead you have to use some
function:

If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
Elseif [ImportDate] > dmax("ImportDate","qry_PSI_ImportDate_Max")
then
msgbox "bla-bla"
end if


--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


"Kelvin Beaton" <kelvin at mccsa dot com> wrote in message
I'm trying to check for two things here.
One that there's an import date, that part work.
Two I want to make sure the date entered is greater then the date
entered.
But it doesn't like the ">" greater then sign.
I've tried this,
[Query]![qry_PSI_ImportDate_Max]![ImportDate]
and this
(>[Query]![qry_PSI_ImportDate_Max]![ImportDate])
and this
([Query]![qry_PSI_ImportDate_Max]![ImportDate])

with no luck.


This code works fine without the OR statement.
----------------------------
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String
If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
Else
----------------------------

How do I get it to look for greater than?

Can someone point me in the right direction?

What am I doing wrong?

Thanks

Kelvin
 
hi Kelvin,
Never watched such kind of training materials, but looks ok for me.

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

Kelvin Beaton said:
Hi Alex

do you know if this course is any good?
http://www.youlearn.com/products/lk-products/A/access2003dev/access2003dev.html
Do you know of any better sources for these topics?

Thanks

Kelvin


Alex Dybenko said:
oops, sorry, this was a typo

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

Kelvin Beaton said:
Hi Alex

Thanks for the reply

Turns out it needed quotes around "[ImportDate]"

Thanks

Kelvin


Hi,
put a stop at that line:

ElseIf [ImportDate] > DMax([ImportDate], "qry_PSI_ImportDate_Max")


then go to debug window ctrl+G and type there:
?[ImportDate]

?DMax([ImportDate], "qry_PSI_ImportDate_Max")

you will see the actual values and this will give you an idea what is
going wrong

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


"Kelvin Beaton" <kelvin at mccsa dot com> wrote in message
Hi Alex

it seems that no matter what date I put in the message "You have
already imported PSI data for this date" pops up.
I've tried dates before and after...

Below is the complete code.
If both of the first conditions are met, I want it to run the code
after the Else statement.

Can you see what's causing this?

Thanks

Kelvin

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String

If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
ElseIf [ImportDate] > DMax([ImportDate],
"qry_PSI_ImportDate_Max") Then
MsgBox "You have already imported PSI data for this date"
Else
DoCmd.RunMacro "mac_UpdateMCCSACleanedTable", , ""
DoCmd.OpenQuery "qry_PSI1_DataCleaner", acViewNormal, acEdit
DoCmd.OpenQuery "qry_PSI2_Append_ClientRecords", acViewNormal,
acEdit
DoCmd.SetWarnings False
DoCmd.OpenQuery "qry_PSI3_MakeTable_ContactLog", acViewNormal,
acEdit
DoCmd.OpenQuery "qry_PSI4_Append_ContactLog", acViewNormal,
acEdit
DoCmd.RunMacro "mac_UpdateMCCSACleanedTable", , ""
MsgBox "PSI Data Imported Successfully."
DoCmd.Close
Exit_Command8_Click:
Exit Sub

Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click

End If
End Sub
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


Hi,
you can not reference query that why, instead you have to use some
function:

If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
Elseif [ImportDate] > dmax("ImportDate","qry_PSI_ImportDate_Max")
then
msgbox "bla-bla"
end if


--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


"Kelvin Beaton" <kelvin at mccsa dot com> wrote in message
I'm trying to check for two things here.
One that there's an import date, that part work.
Two I want to make sure the date entered is greater then the date
entered.
But it doesn't like the ">" greater then sign.
I've tried this,
[Query]![qry_PSI_ImportDate_Max]![ImportDate]
and this
(>[Query]![qry_PSI_ImportDate_Max]![ImportDate])
and this
([Query]![qry_PSI_ImportDate_Max]![ImportDate])

with no luck.


This code works fine without the OR statement.
----------------------------
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String
If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
Else
----------------------------

How do I get it to look for greater than?

Can someone point me in the right direction?

What am I doing wrong?

Thanks

Kelvin
 
Hi Alex

This code is till not working properly...
ElseIf Me.ImportDate > DMax("[ImportDate]", "qry_PSI_importdate_max")
Then
MsgBox "You have already imported PSI data for this date"

It doesn't stop me from importing for the same date...
Can you see an reason for this?
I want it to keep the user from importing data for the same date...

Thanks

Kelvin

++++++++++++++++++++++++++++++++++++++++++++++
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String

If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
ElseIf Me.ImportDate > DMax("[ImportDate]", "qry_PSI_importdate_max")
Then
MsgBox "You have already imported PSI data for this date"
Else
DoCmd.RunMacro "mac_ImportPSIData", , ""
MsgBox "PSI Data Imported Successfully."
Exit_Command8_Click:
Exit Sub

Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click

End If
End Sub
++++++++++++++++++++++++++++++++++++++++++++++


Alex Dybenko said:
hi Kelvin,
Never watched such kind of training materials, but looks ok for me.

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

Kelvin Beaton said:
Hi Alex

do you know if this course is any good?
http://www.youlearn.com/products/lk-products/A/access2003dev/access2003dev.html
Do you know of any better sources for these topics?

Thanks

Kelvin


Alex Dybenko said:
oops, sorry, this was a typo

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

"Kelvin Beaton" <kelvin at mccsa dot com> wrote in message
Hi Alex

Thanks for the reply

Turns out it needed quotes around "[ImportDate]"

Thanks

Kelvin


Hi,
put a stop at that line:

ElseIf [ImportDate] > DMax([ImportDate], "qry_PSI_ImportDate_Max")


then go to debug window ctrl+G and type there:
?[ImportDate]

?DMax([ImportDate], "qry_PSI_ImportDate_Max")

you will see the actual values and this will give you an idea what is
going wrong

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


"Kelvin Beaton" <kelvin at mccsa dot com> wrote in message
Hi Alex

it seems that no matter what date I put in the message "You have
already imported PSI data for this date" pops up.
I've tried dates before and after...

Below is the complete code.
If both of the first conditions are met, I want it to run the code
after the Else statement.

Can you see what's causing this?

Thanks

Kelvin

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String

If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
ElseIf [ImportDate] > DMax([ImportDate],
"qry_PSI_ImportDate_Max") Then
MsgBox "You have already imported PSI data for this date"
Else
DoCmd.RunMacro "mac_UpdateMCCSACleanedTable", , ""
DoCmd.OpenQuery "qry_PSI1_DataCleaner", acViewNormal, acEdit
DoCmd.OpenQuery "qry_PSI2_Append_ClientRecords", acViewNormal,
acEdit
DoCmd.SetWarnings False
DoCmd.OpenQuery "qry_PSI3_MakeTable_ContactLog", acViewNormal,
acEdit
DoCmd.OpenQuery "qry_PSI4_Append_ContactLog", acViewNormal,
acEdit
DoCmd.RunMacro "mac_UpdateMCCSACleanedTable", , ""
MsgBox "PSI Data Imported Successfully."
DoCmd.Close
Exit_Command8_Click:
Exit Sub

Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click

End If
End Sub
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


Hi,
you can not reference query that why, instead you have to use some
function:

If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
Elseif [ImportDate] > dmax("ImportDate","qry_PSI_ImportDate_Max")
then
msgbox "bla-bla"
end if


--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


"Kelvin Beaton" <kelvin at mccsa dot com> wrote in message
I'm trying to check for two things here.
One that there's an import date, that part work.
Two I want to make sure the date entered is greater then the date
entered.
But it doesn't like the ">" greater then sign.
I've tried this,
[Query]![qry_PSI_ImportDate_Max]![ImportDate]
and this
(>[Query]![qry_PSI_ImportDate_Max]![ImportDate])
and this
([Query]![qry_PSI_ImportDate_Max]![ImportDate])

with no luck.


This code works fine without the OR statement.
----------------------------
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String
If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
Else
----------------------------

How do I get it to look for greater than?

Can someone point me in the right direction?

What am I doing wrong?

Thanks

Kelvin
 
Given the error message you're using, I think maybe you wanted an = instead
of a > in your ElseIf statement.


Rob

Kelvin Beaton said:
Hi Alex

This code is till not working properly...
ElseIf Me.ImportDate > DMax("[ImportDate]", "qry_PSI_importdate_max")
Then
MsgBox "You have already imported PSI data for this date"

It doesn't stop me from importing for the same date...
Can you see an reason for this?
I want it to keep the user from importing data for the same date...

Thanks

Kelvin

++++++++++++++++++++++++++++++++++++++++++++++
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String

If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
ElseIf Me.ImportDate > DMax("[ImportDate]", "qry_PSI_importdate_max")
Then
MsgBox "You have already imported PSI data for this date"
Else
DoCmd.RunMacro "mac_ImportPSIData", , ""
MsgBox "PSI Data Imported Successfully."
Exit_Command8_Click:
Exit Sub

Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click

End If
End Sub
++++++++++++++++++++++++++++++++++++++++++++++


Alex Dybenko said:
hi Kelvin,
Never watched such kind of training materials, but looks ok for me.

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

Kelvin Beaton said:
Hi Alex

do you know if this course is any good?
http://www.youlearn.com/products/lk-products/A/access2003dev/access2003dev.html
Do you know of any better sources for these topics?

Thanks

Kelvin


oops, sorry, this was a typo

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

"Kelvin Beaton" <kelvin at mccsa dot com> wrote in message
Hi Alex

Thanks for the reply

Turns out it needed quotes around "[ImportDate]"

Thanks

Kelvin


Hi,
put a stop at that line:

ElseIf [ImportDate] > DMax([ImportDate], "qry_PSI_ImportDate_Max")


then go to debug window ctrl+G and type there:
?[ImportDate]

?DMax([ImportDate], "qry_PSI_ImportDate_Max")

you will see the actual values and this will give you an idea what is
going wrong

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


"Kelvin Beaton" <kelvin at mccsa dot com> wrote in message
Hi Alex

it seems that no matter what date I put in the message "You have
already imported PSI data for this date" pops up.
I've tried dates before and after...

Below is the complete code.
If both of the first conditions are met, I want it to run the code
after the Else statement.

Can you see what's causing this?

Thanks

Kelvin

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String

If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
ElseIf [ImportDate] > DMax([ImportDate],
"qry_PSI_ImportDate_Max") Then
MsgBox "You have already imported PSI data for this date"
Else
DoCmd.RunMacro "mac_UpdateMCCSACleanedTable", , ""
DoCmd.OpenQuery "qry_PSI1_DataCleaner", acViewNormal, acEdit
DoCmd.OpenQuery "qry_PSI2_Append_ClientRecords",
acViewNormal, acEdit
DoCmd.SetWarnings False
DoCmd.OpenQuery "qry_PSI3_MakeTable_ContactLog",
acViewNormal, acEdit
DoCmd.OpenQuery "qry_PSI4_Append_ContactLog", acViewNormal,
acEdit
DoCmd.RunMacro "mac_UpdateMCCSACleanedTable", , ""
MsgBox "PSI Data Imported Successfully."
DoCmd.Close
Exit_Command8_Click:
Exit Sub

Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click

End If
End Sub
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


message Hi,
you can not reference query that why, instead you have to use some
function:

If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
Elseif [ImportDate] >
dmax("ImportDate","qry_PSI_ImportDate_Max") then
msgbox "bla-bla"
end if


--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


"Kelvin Beaton" <kelvin at mccsa dot com> wrote in message
I'm trying to check for two things here.
One that there's an import date, that part work.
Two I want to make sure the date entered is greater then the date
entered.
But it doesn't like the ">" greater then sign.
I've tried this,
[Query]![qry_PSI_ImportDate_Max]![ImportDate]
and this
(>[Query]![qry_PSI_ImportDate_Max]![ImportDate])
and this
([Query]![qry_PSI_ImportDate_Max]![ImportDate])

with no luck.


This code works fine without the OR statement.
----------------------------
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String
If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
Else
----------------------------

How do I get it to look for greater than?

Can someone point me in the right direction?

What am I doing wrong?

Thanks

Kelvin
 
Hi,
or perhaps <=


--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

Robert Morley said:
Given the error message you're using, I think maybe you wanted an =
instead of a > in your ElseIf statement.


Rob

Kelvin Beaton said:
Hi Alex

This code is till not working properly...
ElseIf Me.ImportDate > DMax("[ImportDate]",
"qry_PSI_importdate_max") Then
MsgBox "You have already imported PSI data for this date"

It doesn't stop me from importing for the same date...
Can you see an reason for this?
I want it to keep the user from importing data for the same date...

Thanks

Kelvin

++++++++++++++++++++++++++++++++++++++++++++++
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String

If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
ElseIf Me.ImportDate > DMax("[ImportDate]",
"qry_PSI_importdate_max") Then
MsgBox "You have already imported PSI data for this date"
Else
DoCmd.RunMacro "mac_ImportPSIData", , ""
MsgBox "PSI Data Imported Successfully."
Exit_Command8_Click:
Exit Sub

Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click

End If
End Sub
++++++++++++++++++++++++++++++++++++++++++++++


Alex Dybenko said:
hi Kelvin,
Never watched such kind of training materials, but looks ok for me.

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

"Kelvin Beaton" <kelvin at mccsa dot com> wrote in message
Hi Alex

do you know if this course is any good?
http://www.youlearn.com/products/lk-products/A/access2003dev/access2003dev.html
Do you know of any better sources for these topics?

Thanks

Kelvin


oops, sorry, this was a typo

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

"Kelvin Beaton" <kelvin at mccsa dot com> wrote in message
Hi Alex

Thanks for the reply

Turns out it needed quotes around "[ImportDate]"

Thanks

Kelvin


Hi,
put a stop at that line:

ElseIf [ImportDate] > DMax([ImportDate], "qry_PSI_ImportDate_Max")


then go to debug window ctrl+G and type there:
?[ImportDate]

?DMax([ImportDate], "qry_PSI_ImportDate_Max")

you will see the actual values and this will give you an idea what
is going wrong

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


"Kelvin Beaton" <kelvin at mccsa dot com> wrote in message
Hi Alex

it seems that no matter what date I put in the message "You have
already imported PSI data for this date" pops up.
I've tried dates before and after...

Below is the complete code.
If both of the first conditions are met, I want it to run the code
after the Else statement.

Can you see what's causing this?

Thanks

Kelvin

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String

If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
ElseIf [ImportDate] > DMax([ImportDate],
"qry_PSI_ImportDate_Max") Then
MsgBox "You have already imported PSI data for this date"
Else
DoCmd.RunMacro "mac_UpdateMCCSACleanedTable", , ""
DoCmd.OpenQuery "qry_PSI1_DataCleaner", acViewNormal, acEdit
DoCmd.OpenQuery "qry_PSI2_Append_ClientRecords",
acViewNormal, acEdit
DoCmd.SetWarnings False
DoCmd.OpenQuery "qry_PSI3_MakeTable_ContactLog",
acViewNormal, acEdit
DoCmd.OpenQuery "qry_PSI4_Append_ContactLog", acViewNormal,
acEdit
DoCmd.RunMacro "mac_UpdateMCCSACleanedTable", , ""
MsgBox "PSI Data Imported Successfully."
DoCmd.Close
Exit_Command8_Click:
Exit Sub

Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click

End If
End Sub
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


message Hi,
you can not reference query that why, instead you have to use some
function:

If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
Elseif [ImportDate] >
dmax("ImportDate","qry_PSI_ImportDate_Max") then
msgbox "bla-bla"
end if


--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


"Kelvin Beaton" <kelvin at mccsa dot com> wrote in message
I'm trying to check for two things here.
One that there's an import date, that part work.
Two I want to make sure the date entered is greater then the date
entered.
But it doesn't like the ">" greater then sign.
I've tried this,
[Query]![qry_PSI_ImportDate_Max]![ImportDate]
and this
(>[Query]![qry_PSI_ImportDate_Max]![ImportDate])
and this
([Query]![qry_PSI_ImportDate_Max]![ImportDate])

with no luck.


This code works fine without the OR statement.
----------------------------
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click
Dim stDocName As String
If IsNull([ImportDate]) Then
MsgBox "You must enter an Import date."
Else
----------------------------

How do I get it to look for greater than?

Can someone point me in the right direction?

What am I doing wrong?

Thanks

Kelvin
 

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

Back
Top