Help, can't add record!

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

Guest

I "borrowed" this code from another form in my db, which works.


stlinkCriteria = "[ClientID]=" & "'" & Me![ClientID] & "'"

If HasData12(ClientID) Then
DoCmd.OpenForm stDocName, , , stlinkCriteria
Else
Dim NewData As String
NewData = Me.ClientID
If Me.Dirty Then Me.Dirty = False
DoCmd.OpenForm stDocName, , , , acFormAdd, acDialog, NewData
End If

I wish to determine if there is a record and then, absent one, add a new
record. Testing for the record works fine -- adding does not.

Can anyone see what I cannot?
 
You did not post the code for HasData12(), so it is hard to say. I also see
you are passsing the variable NewData in the OpenArgs argument of the
OpenForm, but you did not post the Load event of the form, so there is no way
to see what the form you are opening is doing. What I would expect to see in
the Load event of the form is:

If Not IsNull(Me.OpenArgs) Then
Me.txtCliendID = Me.OpenArgs
End If

This would see if a value was passed to it and if so, would put the value in
the control on the form where you would enter the Client ID
 
Thanks....it's that pesky OpenArgs I forgot about.

Works fine now -- appreciate it.
--
Thanks for your help,
Chris


Klatuu said:
You did not post the code for HasData12(), so it is hard to say. I also see
you are passsing the variable NewData in the OpenArgs argument of the
OpenForm, but you did not post the Load event of the form, so there is no way
to see what the form you are opening is doing. What I would expect to see in
the Load event of the form is:

If Not IsNull(Me.OpenArgs) Then
Me.txtCliendID = Me.OpenArgs
End If

This would see if a value was passed to it and if so, would put the value in
the control on the form where you would enter the Client ID
Chris said:
I "borrowed" this code from another form in my db, which works.


stlinkCriteria = "[ClientID]=" & "'" & Me![ClientID] & "'"

If HasData12(ClientID) Then
DoCmd.OpenForm stDocName, , , stlinkCriteria
Else
Dim NewData As String
NewData = Me.ClientID
If Me.Dirty Then Me.Dirty = False
DoCmd.OpenForm stDocName, , , , acFormAdd, acDialog, NewData
End If

I wish to determine if there is a record and then, absent one, add a new
record. Testing for the record works fine -- adding does not.

Can anyone see what I cannot?
 
Great.
Do others a favor and rate the post, please. Others searching for an answer
will be able to find the post and get the help they need.

Chris said:
Thanks....it's that pesky OpenArgs I forgot about.

Works fine now -- appreciate it.
--
Thanks for your help,
Chris


Klatuu said:
You did not post the code for HasData12(), so it is hard to say. I also see
you are passsing the variable NewData in the OpenArgs argument of the
OpenForm, but you did not post the Load event of the form, so there is no way
to see what the form you are opening is doing. What I would expect to see in
the Load event of the form is:

If Not IsNull(Me.OpenArgs) Then
Me.txtCliendID = Me.OpenArgs
End If

This would see if a value was passed to it and if so, would put the value in
the control on the form where you would enter the Client ID
Chris said:
I "borrowed" this code from another form in my db, which works.


stlinkCriteria = "[ClientID]=" & "'" & Me![ClientID] & "'"

If HasData12(ClientID) Then
DoCmd.OpenForm stDocName, , , stlinkCriteria
Else
Dim NewData As String
NewData = Me.ClientID
If Me.Dirty Then Me.Dirty = False
DoCmd.OpenForm stDocName, , , , acFormAdd, acDialog, NewData
End If

I wish to determine if there is a record and then, absent one, add a new
record. Testing for the record works fine -- adding does not.

Can anyone see what I cannot?
 
Back
Top