Wrong datatype on this statement error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am getting a datatype error on this taatement. I think that it has to do
with the SSN. The SSN is suppose to be text do I have this right?

DoCmd.OpenForm stDocName, , , stLinkCriteria, , , SNN
 
I don't see anything in this code step that would throw that
error....assuming that stDocName and stLinkCriteria and SNN all have been
dimensioned as string variables.

Post more of the code that leads up to this step.
 
Dim qd As DAO.QueryDef
Dim db As DAO.Database
Set db = CurrentDb


strSQL = "INSERT INTO Provider (SSN, SetA, SetB, SetC) " & _
"VALUES ('" & Me!SSN & "', 0, 0, 0);"

Set qd = db.CreateQueryDef("", strSQL)
qd.Execute dbFailOnError




Me.Blank = 0
DoCmd.GoToRecord , , acNewRec



End If

If checkSet1 = 1 Then
stDocName = "PHQ"
DoCmd.OpenForm stDocName, , , stLinkCriteria, , , SNN

Else
stDocName = "PHQ2"
DoCmd.OpenForm stDocName, , , stLinkCriteria, , , SSN
End If
 
You use SSN in one step, and SNN in another. As you don't dimension SNN in
your code, I assume that it is a typo of SSN, where SSN is a control on the
form.

Correct the typo... does the error go away?
--

Ken Snell
<MS ACCESS MVP>
 
Is the SSN textbox bound to a field? Can the SSN textbox be a Null value?
Why not use

DoCmd.OpenForm stDocName, , , stLinkCriteria, , , Me!SNN.Value


--

Ken Snell
<MS ACCESS MVP>
 
Yes it is a bound field. It is definately not Null. I will try what you
suggested to see fi that helps.
 
Ok using what you suggested got rid of that error. But my SSN isn't carrying
over now to the new form using the open args:

Private Sub Form_Open(Cancel As Integer)
If Me.OpenArgs <> "" Then Me.SSN.DefaultValue = Me.OpenArgs
End Sub

I also tried this and it didn't work either.
If Me.OpenArgs <> "" Then Me.SSN.Value.DefaultValue = Me.OpenArgs
 
Using the form's open event is too soon to write values into controls or
fields for the form. Use the form's load event instead.

--

Ken Snell
<MS ACCESS MVP>
 
Back
Top