Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I open a form in Data entry mode or not?? 1

Status
Not open for further replies.

jasonmac

Programmer
Nov 14, 2002
175
US
Hello everyone. I have a form I using as kind of a menu. I'm using access '97 by the way. My form has two buttons. When the first button is clicked I want the form it opens to open in data entry mode. If the second button is clicked I would like the form to open NOT in data entry mode. How can I accopmlish this. I have tried the following code to open the form in data entry mode but it doesn't work.

Private Sub cmdNewAPQP_Click()

DoCmd.OpenForm "frmAPQP", acNormal

Forms!frmAPQP.DataEntry = True

DoCmd.Close acForm, "frmAPQPFrontEnd"
End Sub

I must be missing something. Can anyone help?

Thanks in advance,
Jason
 
Try this:

DoCmd.OpenForm YourFormName, , , , acFormAdd

HTH,
Eric
 
That worked like a charm although I realized that it wasn't working earlier because my form was based on a query and not a table. I am trying to eliminate redundant froms. Is there a way to define the record source upon opening the form?
 
From within the form:
me.form.recordsource="YourRS"


Outside the form
Forms!YourForm.RecordSource = "YourRS"

HTH,
Eric
 
Can you be a little bit more specific Eric? I'm not sure I'm picking up what you putting down.
 
From within the form:
Say you have two buttons, cmdButton1 and cmdButton2, on a form named frmTest to set the record source for the form.

In cmdButton1's on click event you would put this code:
me.form.recordsource="YourRecordSource1"
me.form.requery
In cmdButton2's on clice event you would put this code:
me.form.recordsource="YourRecordSource2"
me.form.requery

If you want to change the recordsource of frmTest by using a button on a different form, the code would look like this:

Forms!frmTest.RecordSource = "YourRecordSource"
Forms!frmTest.requery

Here's an example of what I think you are trying to do.

From your switchboard or navigational form, when you click a button to open your form frmAPQP and you want the record set to be quQuery1.

docmd.openform "frmAPQP",,,,acFormAdd
forms!frmAPQP.recordsource="quQuery1"
forms!frmAPQP.requery
forms!frmAPQP.setfocus


HTH,
Eric



 
Eric,

It worked like a charm. A star to you and thanks again!

~Jason
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top