Run Time error 94 here it the sql

G

Guest

In my forms report date range it is giving me a response of "run time error
94 invalid use of null. here is the sql. I am new so be patient! I ran
debug and it says the problem is in Me.Caption = Me. OpenArgs??????? Why

Private Sub Form_Open(Cancel As Integer)
Me.Caption = Me.OpenArgs
End Sub
Private Sub Preview_Click()
If IsNull([BeginDate]) Or IsNull([EndDate]) Then
MsgBox "You must enter both beginning and ending dates."
DoCmd.GoToControl "BeginDate"
Else
If [BeginDate] > [EndDate] Then
MsgBox "Ending date must be greater than Beginning date."
DoCmd.GoToControl "BeginDate"
Else
Me.Visible = False
End If
End If
End Sub
 
U

UTYNUTRYNUTUNT

esparzaone said:
In my forms report date range it is giving me a response of "run time error
94 invalid use of null. here is the sql. I am new so be patient! I ran
debug and it says the problem is in Me.Caption = Me. OpenArgs??????? Why

Private Sub Form_Open(Cancel As Integer)gretbe?
Me.Caption = Me.OpenArgs
End Sub
Private Sub Preview_Click()
If IsNull([BeginDate]) Or IsNull([EndDate]) Then
MsgBox "You must enter both beginning and ending dates."?
DoCmd.GoToControl "BeginDate"
Else
If [BeginDate] > [EndDate] Then
MsgBox "Ending date must be greater than Beginning date."?
DoCmd.GoToControl "BeginDate"
Else
Me.Visible = False
End If
End If
End Sub
 
D

Dirk Goldgar

esparzaone said:
In my forms report date range it is giving me a response of "run time
error 94 invalid use of null. here is the sql. I am new so be
patient! I ran debug and it says the problem is in Me.Caption = Me.
OpenArgs??????? Why

Private Sub Form_Open(Cancel As Integer)
Me.Caption = Me.OpenArgs
End Sub
Private Sub Preview_Click()
If IsNull([BeginDate]) Or IsNull([EndDate]) Then
MsgBox "You must enter both beginning and ending dates."
DoCmd.GoToControl "BeginDate"
Else
If [BeginDate] > [EndDate] Then
MsgBox "Ending date must be greater than Beginning date."
DoCmd.GoToControl "BeginDate"
Else
Me.Visible = False
End If
End If
End Sub

(Note: that's not SQL, it's VBA. SQL is the query language that is
processed by the database engine itself; VBA is the programming
language used to control Microsoft Access and other applications.)

You're probably having the problem because the form's OpenArgs property
is Null, meaning no argument was passed when the form was opened, and
you're trying to assign that Null value to the form's Caption property,
which can only accept a character string. I suggest you modify the code
in the form's Open event as follows:

'----- start of revised code -----
Private Sub Form_Open(Cancel As Integer)

Dim strArgs As String

strArgs = Me.OpenArgs & vbNullString

If Len(strArgs) > 0 Then
Me.Caption = strArgs
End If

End Sub
'----- end of revised code -----

What that VBA code does is (1) convert the OpenArgs value to a string if
necessary, and assign that string to the variable "strArgs", (2) check
to see if the value of strArgs is longer than 0 characters, and (3) if
it is, set the form's Caption to that value.
 

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