Form data not saving

E

Emma

Hi all,

I have a form, "Master Jobs Data Entry Form", on which there is a combo box
"Job_Type" that has a variety of items in it that when some of them are
selected various things happen. One item may open another form, another item
may cause an option box to open, etc. . . using a select case statement as
follows:

Private Sub Job_Type_AfterUpdate()

Dim MyOpenArgs As String

MyOpenArgs = Me!Job_ID & "," & Me!cbo_Account_No & "," &
Me!cbo_Account_No.Column(1)



Select Case Me!Job_Type
' Case 1 'Addendum
' DoCmd.OpenForm ""

Case 5 'Evaluations

DoCmd.OpenForm "Frm_Tbl_Evaluation_Details", , , , acFormAdd, ,
MyOpenArgs

Case 7 'Contract Options
DoCmd.GoToControl "comments"
Me!Frame_Contract_Type.Visible = True

Case 8 'Rentals

DoCmd.OpenForm "Frm_Rental_Detail", , , , acFormAdd, , MyOpenArgs


Case 12 'debit memos

DoCmd.OpenForm "Frm_Tbl_Debit_Memo", , , , acFormAdd, , MyOpenArgs

Case Else 'go to comments
DoCmd.GoToControl "Comments"

End Select

End Sub

I am having a problem getting the data to save in the "Master Jobs Data
Entry Form". What I mean is that in order to exit this form I am having to
move to a new record and then move back to the form.

Can someone tell me why this is happening? It's like when a selection is
made in the combo box "Job_Type" and a pop-up form opens the Master Jobs Data
Entry Form data is not being saved so when I open another form based on the
primary key of the Master Jobs Data Entry Form, the record has not yet been
saved and I can't print a report based on any information in that record.

What do I need to do to get the record in the "Master_Jobs_Data_Entry" form
saved when the pop-up forms open?

Thank you for any help you can provide.

Sincerely,

Thank you!
 
S

Sandra Daigle

If you want the record to be saved when you open the pop-up form then you
have to explicitly save it. You can do this by setting the Dirty property to
false. Note that by attempting to save the record you may cause other code
to run that could interfere with your attempt to save the record (ie,
BeforeUpdate event).

me.dirty=false

Just add this line prior to each docmd.openform (or before the select case
if you don't care that the record is saved in the Case Else situation).
 
T

Tom Lake

Sandra Daigle said:
If you want the record to be saved when you open the pop-up form then you have to
explicitly save it. You can do this by setting the Dirty property to false. Note
that by attempting to save the record you may cause other code to run that could
interfere with your attempt to save the record (ie, BeforeUpdate event).

Would a

RunCommand acCmdSaveRecord

work as well?

Tom Lake
 
S

Sandra Daigle

Yes. However I prefer to use the methods and properties of the object (Form
in this case) when possible instead of using the Docmd object. Docmd works
on the object that has focus so in some cases you may have unexpected
results while me.dirty=false can only operate on the form to which the class
module belongs. Docmd also sometimes causes problems with debugging - not
critical in the runtime but a nuisance during development.
 
E

Emma

Hi Sandra,

I have tried setting the Dirty property to false as follows:

Case 8 'Rentals

DoCmd.OpenForm "Frm_Rental_Detail", , , , acFormAdd, , MyOpenArgs
Me.Dirty = False

but I get an error message saying:

Run-time error '2101': The setting you entered isn't valid for this property.

What could be causing this???

Sincerely,

Sandra Daigle said:
If you want the record to be saved when you open the pop-up form then you
have to explicitly save it. You can do this by setting the Dirty property to
false. Note that by attempting to save the record you may cause other code
to run that could interfere with your attempt to save the record (ie,
BeforeUpdate event).

me.dirty=false

Just add this line prior to each docmd.openform (or before the select case
if you don't care that the record is saved in the Case Else situation).

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

Hi all,

I have a form, "Master Jobs Data Entry Form", on which there is a
combo box "Job_Type" that has a variety of items in it that when some
of them are selected various things happen. One item may open
another form, another item may cause an option box to open, etc. . .
using a select case statement as follows:

Private Sub Job_Type_AfterUpdate()

Dim MyOpenArgs As String

MyOpenArgs = Me!Job_ID & "," & Me!cbo_Account_No & "," &
Me!cbo_Account_No.Column(1)



Select Case Me!Job_Type
' Case 1 'Addendum
' DoCmd.OpenForm ""

Case 5 'Evaluations

DoCmd.OpenForm "Frm_Tbl_Evaluation_Details", , , , acFormAdd, ,
MyOpenArgs

Case 7 'Contract
Options DoCmd.GoToControl "comments"
Me!Frame_Contract_Type.Visible = True

Case 8 'Rentals

DoCmd.OpenForm "Frm_Rental_Detail", , , , acFormAdd, ,
MyOpenArgs


Case 12 'debit memos

DoCmd.OpenForm "Frm_Tbl_Debit_Memo", , , , acFormAdd, ,
MyOpenArgs

Case Else 'go to comments
DoCmd.GoToControl "Comments"

End Select

End Sub

I am having a problem getting the data to save in the "Master Jobs
Data Entry Form". What I mean is that in order to exit this form I
am having to move to a new record and then move back to the form.

Can someone tell me why this is happening? It's like when a
selection is made in the combo box "Job_Type" and a pop-up form opens
the Master Jobs Data Entry Form data is not being saved so when I
open another form based on the primary key of the Master Jobs Data
Entry Form, the record has not yet been saved and I can't print a
report based on any information in that record.

What do I need to do to get the record in the
"Master_Jobs_Data_Entry" form saved when the pop-up forms open?

Thank you for any help you can provide.

Sincerely,

Thank you!
 
S

Sandra Daigle

I think this is occuring because the record can't be saved - are there some
required fields missing?

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

Hi Sandra,

I have tried setting the Dirty property to false as follows:

Case 8 'Rentals

DoCmd.OpenForm "Frm_Rental_Detail", , , , acFormAdd, ,
MyOpenArgs Me.Dirty = False

but I get an error message saying:

Run-time error '2101': The setting you entered isn't valid for this
property.

What could be causing this???

Sincerely,

Sandra Daigle said:
If you want the record to be saved when you open the pop-up form
then you have to explicitly save it. You can do this by setting the
Dirty property to false. Note that by attempting to save the record
you may cause other code to run that could interfere with your
attempt to save the record (ie, BeforeUpdate event).

me.dirty=false

Just add this line prior to each docmd.openform (or before the
select case if you don't care that the record is saved in the Case
Else situation).

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

Hi all,

I have a form, "Master Jobs Data Entry Form", on which there is a
combo box "Job_Type" that has a variety of items in it that when
some of them are selected various things happen. One item may open
another form, another item may cause an option box to open, etc. . .
using a select case statement as follows:

Private Sub Job_Type_AfterUpdate()

Dim MyOpenArgs As String

MyOpenArgs = Me!Job_ID & "," & Me!cbo_Account_No & "," &
Me!cbo_Account_No.Column(1)



Select Case Me!Job_Type
' Case 1 'Addendum
' DoCmd.OpenForm ""

Case 5 'Evaluations

DoCmd.OpenForm "Frm_Tbl_Evaluation_Details", , , ,
acFormAdd, , MyOpenArgs

Case 7 'Contract
Options DoCmd.GoToControl "comments"
Me!Frame_Contract_Type.Visible = True

Case 8 'Rentals

DoCmd.OpenForm "Frm_Rental_Detail", , , , acFormAdd, ,
MyOpenArgs


Case 12 'debit memos

DoCmd.OpenForm "Frm_Tbl_Debit_Memo", , , , acFormAdd, ,
MyOpenArgs

Case Else 'go to
comments DoCmd.GoToControl "Comments"

End Select

End Sub

I am having a problem getting the data to save in the "Master Jobs
Data Entry Form". What I mean is that in order to exit this form I
am having to move to a new record and then move back to the form.

Can someone tell me why this is happening? It's like when a
selection is made in the combo box "Job_Type" and a pop-up form
opens the Master Jobs Data Entry Form data is not being saved so
when I open another form based on the primary key of the Master
Jobs Data Entry Form, the record has not yet been saved and I can't
print a report based on any information in that record.

What do I need to do to get the record in the
"Master_Jobs_Data_Entry" form saved when the pop-up forms open?

Thank you for any help you can provide.

Sincerely,

Thank you!
 
E

Emma

Yes, there is one required field but that is being filled in prior to the
Job_Type being selected. There is an option box that appears should another
case be selected, but the options are not required? Could that still have
something to do with it???

Sandra Daigle said:
I think this is occuring because the record can't be saved - are there some
required fields missing?

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

Hi Sandra,

I have tried setting the Dirty property to false as follows:

Case 8 'Rentals

DoCmd.OpenForm "Frm_Rental_Detail", , , , acFormAdd, ,
MyOpenArgs Me.Dirty = False

but I get an error message saying:

Run-time error '2101': The setting you entered isn't valid for this
property.

What could be causing this???

Sincerely,

Sandra Daigle said:
If you want the record to be saved when you open the pop-up form
then you have to explicitly save it. You can do this by setting the
Dirty property to false. Note that by attempting to save the record
you may cause other code to run that could interfere with your
attempt to save the record (ie, BeforeUpdate event).

me.dirty=false

Just add this line prior to each docmd.openform (or before the
select case if you don't care that the record is saved in the Case
Else situation).

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


Emma wrote:
Hi all,

I have a form, "Master Jobs Data Entry Form", on which there is a
combo box "Job_Type" that has a variety of items in it that when
some of them are selected various things happen. One item may open
another form, another item may cause an option box to open, etc. . .
using a select case statement as follows:

Private Sub Job_Type_AfterUpdate()

Dim MyOpenArgs As String

MyOpenArgs = Me!Job_ID & "," & Me!cbo_Account_No & "," &
Me!cbo_Account_No.Column(1)



Select Case Me!Job_Type
' Case 1 'Addendum
' DoCmd.OpenForm ""

Case 5 'Evaluations

DoCmd.OpenForm "Frm_Tbl_Evaluation_Details", , , ,
acFormAdd, , MyOpenArgs

Case 7 'Contract
Options DoCmd.GoToControl "comments"
Me!Frame_Contract_Type.Visible = True

Case 8 'Rentals

DoCmd.OpenForm "Frm_Rental_Detail", , , , acFormAdd, ,
MyOpenArgs


Case 12 'debit memos

DoCmd.OpenForm "Frm_Tbl_Debit_Memo", , , , acFormAdd, ,
MyOpenArgs

Case Else 'go to
comments DoCmd.GoToControl "Comments"

End Select

End Sub

I am having a problem getting the data to save in the "Master Jobs
Data Entry Form". What I mean is that in order to exit this form I
am having to move to a new record and then move back to the form.

Can someone tell me why this is happening? It's like when a
selection is made in the combo box "Job_Type" and a pop-up form
opens the Master Jobs Data Entry Form data is not being saved so
when I open another form based on the primary key of the Master
Jobs Data Entry Form, the record has not yet been saved and I can't
print a report based on any information in that record.

What do I need to do to get the record in the
"Master_Jobs_Data_Entry" form saved when the pop-up forms open?

Thank you for any help you can provide.

Sincerely,

Thank you!
 
S

Sandra Daigle

There is something interfering with the save - try taking out the code and
then manually trying to save the record and see what messages you get.

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

Yes, there is one required field but that is being filled in prior to
the Job_Type being selected. There is an option box that appears
should another case be selected, but the options are not required?
Could that still have something to do with it???

Sandra Daigle said:
I think this is occuring because the record can't be saved - are
there some required fields missing?

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.

Hi Sandra,

I have tried setting the Dirty property to false as follows:

Case 8 'Rentals

DoCmd.OpenForm "Frm_Rental_Detail", , , , acFormAdd, ,
MyOpenArgs Me.Dirty = False

but I get an error message saying:

Run-time error '2101': The setting you entered isn't valid for this
property.

What could be causing this???

Sincerely,

:

If you want the record to be saved when you open the pop-up form
then you have to explicitly save it. You can do this by setting the
Dirty property to false. Note that by attempting to save the record
you may cause other code to run that could interfere with your
attempt to save the record (ie, BeforeUpdate event).

me.dirty=false

Just add this line prior to each docmd.openform (or before the
select case if you don't care that the record is saved in the Case
Else situation).

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


Emma wrote:
Hi all,

I have a form, "Master Jobs Data Entry Form", on which there is a
combo box "Job_Type" that has a variety of items in it that when
some of them are selected various things happen. One item may
open another form, another item may cause an option box to open,
etc. . . using a select case statement as follows:

Private Sub Job_Type_AfterUpdate()

Dim MyOpenArgs As String

MyOpenArgs = Me!Job_ID & "," & Me!cbo_Account_No & "," &
Me!cbo_Account_No.Column(1)



Select Case Me!Job_Type
' Case 1 'Addendum
' DoCmd.OpenForm ""

Case 5
'Evaluations

DoCmd.OpenForm "Frm_Tbl_Evaluation_Details", , , ,
acFormAdd, , MyOpenArgs

Case 7 'Contract
Options DoCmd.GoToControl "comments"
Me!Frame_Contract_Type.Visible = True

Case 8 'Rentals

DoCmd.OpenForm "Frm_Rental_Detail", , , , acFormAdd, ,
MyOpenArgs


Case 12 'debit
memos

DoCmd.OpenForm "Frm_Tbl_Debit_Memo", , , , acFormAdd, ,
MyOpenArgs

Case Else 'go to
comments DoCmd.GoToControl "Comments"

End Select

End Sub

I am having a problem getting the data to save in the "Master Jobs
Data Entry Form". What I mean is that in order to exit this form
I am having to move to a new record and then move back to the
form.

Can someone tell me why this is happening? It's like when a
selection is made in the combo box "Job_Type" and a pop-up form
opens the Master Jobs Data Entry Form data is not being saved so
when I open another form based on the primary key of the Master
Jobs Data Entry Form, the record has not yet been saved and I
can't print a report based on any information in that record.

What do I need to do to get the record in the
"Master_Jobs_Data_Entry" form saved when the pop-up forms open?

Thank you for any help you can provide.

Sincerely,

Thank you!
 

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