Subform on Unbound Form...

G

Guest

I had Posted this in "General Questions" last week. Couldn't
solve preventing Blank records - see below.

I have a Form w/ unbound controls populated by a dropdown
w/ a Field having the Primary Key.

Based on the PK value, a Subform is bound to "many" values
in another Table and displays those records w/ a foreign key
having the PK value on the Main Form.

What is the best way to "design" the Subform so no "Blank"
records appear?...IE see the "star" entry row??

Each time I enter the PK record (the "one" in the one-to-many),
I'm getting an additional Blank record in the "many" Table.

TIA - Bob
 
G

Guest

That allows you to add new records in the subform. You can make it
disappear, but it would take some VBA coding to hide it and to present it if
the user needs to add new records. If you make it disappear, the user can't
add any records until you bring it back. I really don't believe it is worth
the effort.
 
G

Guest

Thank you...yes, I need the "star" to add Records.

The problem is...I'm getting a Blank record when the User enters the "One"
(of the
One-to-Many) Record on the Unbound Form.

Bob
 
G

Guest

Then to actually add records, you would need an "Add" command button that
would change it to yes.
 
S

Steve Schapel

True. It wasn't clear that Bob wanted to add new records on the
subform. But if so, that's standard procedure in my apps. Anyway, it
has now emerged that we have both apparently misinterpreted the actual
problem.
 
G

Guest

This may be working...the code is stripped...the dropdown "cboRecs" selects a
Record. By definition, additions/ edits can only be made if the Record's
date is today's date.

Adding "changes" forces code to duplicate the record to the Current
date...per the Client's request...which works.

The code...
If Not IsNull(cboRecs) Then
Lbl2048.Caption = "Existing Record"
Lbl2048.BackColor = 16777088: Lbl2048.Visible = True
cmdDupRec.Visible = True: lblNewRec.Visible = False
Me.TheParts.Form.Visible = True: Me.TheParts.Form.Requery
If CDate(GDate) = Date Then
Me.TheParts.Form.AllowAdditions = True
Me.TheParts.Form.AllowEdits = True
Else
Me.TheParts.Form.AllowAdditions = False
Me.TheParts.Form.AllowEdits = False
End If
.......
End If

Thank you both - Bob
 
A

Albert D. Kallal

Steve - Thank you...but how do I add Records??

I have a good number of sub-forms where

1) I did not want the extra record
2) I did need the user to have an ability to add records

I have screen shots here where I placed a button on the sub-form

In this set of screen shots, it is not even a sub-form, and again I provided
a button

http://www.kallal.ca/ridestutorialp/drivers.htm

The above add code behind the button is:

DoCmd.OpenForm "NameOfForm", , , , acFormAdd

As a suggestion, that form that pops open can have the allow additions set =
no, and that means that the user can only enter ONE record, and then must
close the form (if you have "many" to enter, then of course leave the allow
additions alone).

The above screen shots were for a form in continues mode, here is a screen
shot (scroll to the last one), and there is MORE then one sub-form on he
screen, and I have a "add button".

http://www.kallal.ca/ridestutorialp/setdriver.htm

Those add buttons simply pass the primary key id, such as:

docmd.OpenForm "forrmname",,,,acFormAdd,,me.parent!id

The code in the before-insert event in the form is

me!fk_id = me.openargs
 

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

Subform w/ Unbound Form 4
must have 2 records in subform 9
Duplicate Form, Subfrom 1
subform new records 11
Many-to-many on form 2
Form/Subform 13
Subform with no records 8
subform populate error 7

Top