View Full Version : How do I Specify a New Record in a Form with a Command Button


Sorrells
01-25-2001, 04:16 AM
Here is the context. I am creating a genealogy database. I have a form based on a single table with the following fields: name, mother, father, spouse, children, DOB, DOD, marriage date. I named it 'Family Group'
From a switchboard, the user can enter all or part of a relative's name and with wildcards, all possible matches are filtered into this form. Fine.

Now I want the user to be able to click on the 'Father's Group' if they are viewing a record they like. The VBA code is to assign the father's name to the name field and the mother's name to the spouse field. Since most married couples names are pretty unique, I think this is all I need to query the table again and display the appropriate fields for the father.

As you would guess, once accomplished, I'd want to do this for the mother for her parentage then finally the hardest of all, selection of the children, when in our ancestors, there could be 7 to 10 in the family. Sounds like fun?!?

But for now, if I could obtain assistance for just the Father, I would be very grateful.

My thoughts are along these lines. Remember I want to use the same form, just have a different record appear.

txtName = txtFather
If Not IsNull(txtMarried_To) Then
txtMarried_To = txtMother
Else
txtMarried_To = txtMother
End If
DoCmd.Requery "txtName" And "txtMarried_to"

But this is returning a type mismatch error.

Do any of you have some thoughts on this?

Thanks,

Sorrells

ntp
01-25-2001, 09:19 AM
The error you are getting is bacause this line

>>>DoCmd.Requery "txtName" And "txtMarried_to"
should be changed to something like this:
>>> Docmd.requery me.txtName.Name
>>> DoCmd.requery me.txtMarried_To.Name

Keep them as separate requeries. I prefer to use me.control.name to refer to a controls name rather than "controlname". Just personal preference but I find it makes things easier and more clear.

also the if statement

If Not IsNull(txtMarried_To) Then
txtMarried_To = txtMother
Else
txtMarried_To = txtMother
End If

no matter what it assigns txtmother to txtMarried_To
Some error in your logic here.

ntp


[This message has been edited by ntp (edited 01-25-2001).]