Help, can't add record!

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?
 
G

Guest

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
 
G

Guest

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?
 
G

Guest

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?
 

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

Similar Threads

Not In List, saving data 3
MsgBox 7
Open Args trouble saving 5
Message appears twice. 4
Problem with Opening Subform 2
Having trouble opening forms 3
A Dirty NotInList 1
How to pass multiple Fields to new Form 2

Top