Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

How open form with certain circumstances

I have a 2nd form which opens from a command button on a 1st form:

DoCmd.OpenForm "frmRequestForPickup", acNormal, , , acFormAdd, acWindowNormal

if the form has never been filled out before.

But if the form has been filled out before I want it to open and show that record which I suppose means it can't open with the acFormAdd in the code.

The way to determine if the form has been filled out before and there is a record entered already is via a field named "PetID".  If the table has a record with PetID matching the field txtPetID in form 1 then display the already existing record.

How?
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You don't actually need to do the dLookup().  Just open the form normally with a where argument.   If the record is found, the form will open to the found record.  If it wasn't found, the form will open to a new record.  So,
DoCmd.OpenForm "frmRequestForPickup", acNormal, ,"[PetID]=" & me.txtPetID , , acWindowNormal

Should do it.