Using Parenthesis in VBA

jo15765

Well-known Member
Joined
Sep 23, 2011
Messages
591
I want to run this statement in VBA (which I know is a valid statement)
Code:
''''''Begin & Finish are input boxes that are receiving values as dates...
WHERE tblnew.partName = 'Muffler' AND (tblnew.partEnteredDate Between " & Begin & " And " & Finish & ") 
And tblnew.supervisorCheck IS NOT NULL AND tblnew.OrderDate IS NOT NULL AND tblnew.Ordered IS NOT NULL"

The statement runs fine, but it doesn't return any results and if I run the query in SQL Server it returns results. That being said, I am thinking that I am missing some parenthesis around pieces of the Where clause....can someone assist?
 
I do have a question regarding vba validation of a date. i know how to check if it is null, but how do I check if the input is Integer only? I tried using IsNumeric, but I may have used it in the wrong syntax as it would not work at all!
 
Upvote 0
Can't you use the IsDate function? Something like:
Code:
If IsDate(textbox1.Value) Then
  dFormatted = Format(CDate(textbox1.Value), "yyyy/mm/dd")
Else
    MsgBox "Enter Valid Date", vbCritical + vbDefaultButton1
End if
 
Upvote 0
Can't you use the IsDate function? Something like:
Code:
If IsDate(textbox1.Value) Then
  dFormatted = Format(CDate(textbox1.Value), "yyyy/mm/dd")
Else
    MsgBox "Enter Valid Date", vbCritical + vbDefaultButton1
End if
This is the syntax I am using, but it is allowing me to input for a date only 08...I want it to also verify that the date input is in this syntax 08/12/2012...I am sure I just need to somehow show the format i want it in, as you did above, but I can't figure out how to do that piece:
Code:
BeginCheck:
    Begin = Application.InputBox(Prompt:="Enter A Date.", Title:="Date")
     If (Begin = "12:00:00 AM" Or IsDate(Begin) <> True) Then
        MsgBox "Please enter a valid date."
        GoTo BeginCheck
    End If
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top