New Record on Continous Form or Subform (Irritating)

G

Guest

Is there a way to hide the new record that is blank on a continuous form or
subform at the bottom. Then have a command button on form header or footer
for new record to display the new record for input. How I have been getting
around this is using a single form. However, since I have been emulating a
listbox using continuos forms, I see this blank record at the end with
autonumber in one of my fields.

Thanks,
 
G

Guest

Set the subform's AllowAdditions property to False to get rid of the blank row.

With the command button open another form bound to the subform's underlying
table or query. If the subform is linked to the parent form you'll need to
pass the value of the linking field to the new form, so the code for the
button's Click event procedure would be like this:

DoCmd.OpenForm "YourNewForm", _
DataMode:=acFormAdd, _
WindowMode:=acDialog, _
OpenArgs:=Me.MyID

Me.Requery

Where MyID is the linking field's name.

In the Open event procedure of the new form put:

If Not IsNull(Me.OpenArgs) Then
Me.MyID.DefaultValue = """" & Me.OpenArgs & """"
End If

There should be a MyID control bound to the field on the new form. You can
set its Visible property to false if you wish to hide it. Note that the
DefaultValue property is a string expression regardless of the data type of
the underlying field, so need to be wrapped in literal quotes as in the above
code.

Ken Sheridan
Stafford, England
 

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