Append query in form

  • Thread starter Thread starter Alex
  • Start date Start date
A

Alex

I have an append query in a form, which is activated when
entering a new form via a command button.

The code I have written is:
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryAppendAnswers"
[Forms]![subfrmQA].Requery
DoCmd.SetWarnings True

This append should only occur once for each instance.
HOwever, if the user should reenter the second form (by
mistake/user error), then the append query runs again and
I end up with double the amount of records.

How do I stop this from happening?

Please help,
alex.
 
How does the user "enter" the second form? From a "first form"? If yes, put
a hidden textbox on that form. Use it to hold a value that tells the first
form if the second form has been entered once already. Each time you enter
the second form, test the value in that textbox. If it's the value that you
write when you have entered the second form once, then don't let user go
into the second form. If it's ok, then write a value to this textbox via
code to tell ACCESS that no more entries can be made to this second form.
 
User enters the second form via the first form (using
OpenForm command button).

I am a self-taught newbie (the worst kind huh) and I am
really not sure how to do what you suggest. Can you give
me more instructions?

Thanks very much for your help,
Alex
-----Original Message-----
How does the user "enter" the second form? From a "first form"? If yes, put
a hidden textbox on that form. Use it to hold a value that tells the first
form if the second form has been entered once already. Each time you enter
the second form, test the value in that textbox. If it's the value that you
write when you have entered the second form once, then don't let user go
into the second form. If it's ok, then write a value to this textbox via
code to tell ACCESS that no more entries can be made to this second form.

--

Ken Snell
<MS ACCESS MVP>

I have an append query in a form, which is activated when
entering a new form via a command button.

The code I have written is:
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryAppendAnswers"
[Forms]![subfrmQA].Requery
DoCmd.SetWarnings True

This append should only occur once for each instance.
HOwever, if the user should reenter the second form (by
mistake/user error), then the append query runs again and
I end up with double the amount of records.

How do I stop this from happening?

Please help,
alex.


.
 
Use a hidden textbox (put a textbox on the form and set its Visible property
to No). Name it txtDoNotOpen.

In the code that opens the second form, use this block of code:

If Len(Me.txtDoNotOpen.Value & "") = 0 Then
Me.txtDoNotOpen.Value = "Opened"
DoCmd.OpenForm "SecondFormName"
Else
MsgBox "You cannot go to this form again."
End If

--

Ken Snell
<MS ACCESS MVP>

Alex said:
User enters the second form via the first form (using
OpenForm command button).

I am a self-taught newbie (the worst kind huh) and I am
really not sure how to do what you suggest. Can you give
me more instructions?

Thanks very much for your help,
Alex
-----Original Message-----
How does the user "enter" the second form? From a "first form"? If yes, put
a hidden textbox on that form. Use it to hold a value that tells the first
form if the second form has been entered once already. Each time you enter
the second form, test the value in that textbox. If it's the value that you
write when you have entered the second form once, then don't let user go
into the second form. If it's ok, then write a value to this textbox via
code to tell ACCESS that no more entries can be made to this second form.

--

Ken Snell
<MS ACCESS MVP>

I have an append query in a form, which is activated when
entering a new form via a command button.

The code I have written is:
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryAppendAnswers"
[Forms]![subfrmQA].Requery
DoCmd.SetWarnings True

This append should only occur once for each instance.
HOwever, if the user should reenter the second form (by
mistake/user error), then the append query runs again and
I end up with double the amount of records.

How do I stop this from happening?

Please help,
alex.


.
 
Back
Top