Open Form with specified Recordset

holiday_intern

New member
Local time
Today, 16:58
Joined
Jul 21, 2005
Messages
8
Open Form with specified Recordset and Autofill

hi, im a beginner in access and want to do something like that:

<edit>this is in the DetailButton_Click() event</edit>

stDocName = "PersonDetails_Form"

DoCmd.RunCommand acCmdSaveRecord

'open form with recordset of person

DoCmd.OpenForm stDocName, , , "[P_ID] = " & Forms![PersonBase_Form]![P_ID]


'now the part i dont know how to do

If Not "[P_ID] = " & Forms![PersonBase_Form]![P_ID] Then
DoCmd.OpenForm stDocName, , acNewRec .....
End If

-> if there is no recordset of the Person, create new recordset with P_ID(hidden) and PersonNumber(visible and editable) from PersonBase
 
Last edited:
ok, maybe my post is not very clear.

what i have is:

person_form
P_ID (PK,AutoNumber,invisible)
PersonNumber (Number, editable by user)
PersonDetail_Button (CommandButton that opens personDetail_Form and
opens recordset of the user if it already exists)
.

personDetail_form
P_ID (ForeignKey, Number)
PersonNumber (Number)
.
.




my problem is:
if there is no detail recordset about a person access opens a blank recordset -> as the foreign key P_ID in personDetail_form is number it has to be input manually but because the user shall stick with PersonNumber i have to autofill when the personDetail_Form is opened.

how do i do to autofill the P_ID and PersonNumber with the values from person_form?

i hope this was more understandable.
 
well, im doing it via combo box now:

a combo box with P_ID and PersonNumber from the person form that fill P_ID and PersonNumber in PersonDetail via:

Private Sub Combo26_AfterUpdate()
Me.P_ID.Value = Me.Combo26.Column(0)
Me.PersonNumber = Me.Combo26.Column(1)
End Sub

(P_ID is hidden in both the combo and the detail_form)

i only have one little problem left:
if i select the PersonNumber in the Combo via Mouseclick everything is ok, but if i select via hitting Enter the fields are not filled and get a message about duplicate values if i try to safe.

i think i only have to tell the combo to fill the fields if i hit enter when a appropriate number is put forward from the combo

i'd very appreciate it if someone can tell me how to solve this.
if im unclear ask.
 
Last edited:
Ok, its just a missing requery for P_ID and PersonNumber in PresonDetail_form.

so whats intresting is why does it requery correctly if i select via mouseclick and don't if i hit enter? so anyone knows where to requery the autofilled textboxes?
 
Last edited:

Users who are viewing this thread

Back
Top Bottom