Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modifying a Record, Sub & Main Forms...

Status
Not open for further replies.

Hammondo

MIS
Jan 14, 2002
23
0
0
NL
Hello Everyone

On my main form (FormA), I have two buttons (ButtonA and Button B), a Subform (SubFormA).

I also have a second form (FormB)... oh and a table (Table1).

SubFormA's record source is a query (on Table1) and a single criteria and will only display a single record. The form is for record display purposes only.. no edits, additions etc allowed.

FormB's record Source is Table1, FormA has no record source.

I would like ButtonA when pressed to open FormB and display the current record displayed in SubFormA, so the record can be modified and saved.

I would like ButtonB when pressed to open FormB and create a new record in Table1.

Make sense? How can I do this?...

Cheers in advance,

Grant.

 
Hallo,

If you look at the help for the OpenForm method you will notice the WHERE clause arguement. This can be used to open a form and display a restricted set of data.

If the Primary Key of Table1 is Key1 then Button A's click event could be:
Code:
Docmd.openform "FormB",acNormal,,"[Key1]=" & Me!SubFormA.Form!Key1
That's if Key1 is a number, use
Code:
Docmd.openform "FormB",acNormal,,"[Key1]='" & Me!SubFormA.Form!Key1 & "'"
if Key1 is a string.

The other OpenForm parameters could be used if you want.

Button B could use
Docmd.openform "FormB",acNormal,,,acFormAdd
I don't know if that would work. Give it a whirl and see what happens...
The alternative is to create a new record using SQL and use the first method to open it.

- Frink



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top