Form not opening correctly

R

Ripper

I trying to get a form to open in add mode with the LocID populated. I tried
to following code to get it to open and it opens with the LocID in the
correctplace, it is just not in add mode. Anyone willing to help?

Private Sub Command29_Click()
On Error GoTo Err_Command29_Click

Dim stDocName As String

stDocName = "frmIssAddAdmin"

DoCmd.OpenForm stDocName, , , "[LocID] = " & Me.LocID, acFormAdd
 
M

Maurice

What do you mean by "Add-mode". The default will be that you can add records
and that exactly what you are doing here. So you could omit the acformAdd
argument.

Why can't you add via this situation? are the navigationbuttons not showing
or are they geyed out?
 
B

Bob Quintal

I trying to get a form to open in add mode with the LocID
populated. I tried to following code to get it to open and it
opens with the LocID in the correctplace, it is just not in
add mode. Anyone willing to help?

Private Sub Command29_Click()
On Error GoTo Err_Command29_Click

Dim stDocName As String

stDocName = "frmIssAddAdmin"

DoCmd.OpenForm stDocName, , , "[LocID] = " & Me.LocID,
acFormAdd

You are opening the form using two mutually exclusive
statements, the first being the Where Clause which filters the
records to where LocID is equal to the value you've put in the
referenced control and the second is give you an empty record.
You can't have it both ways.
Use the openargs feature instead. You will need to put some code
in the form to accept an process the openargs, and modify your
call to
DoCmd.OpenForm stDocName, , , ,acFormAdd,, me.LocID,
 

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

Opening Arguments 1
Open Form with subform Values 1
Debugger runs but unwanted 8
Continuous Form Default Value 3
Criteria when opening form 1
If Statements 4
Form to add and update data 1
Printing Porblem 0

Top