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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

auto populate fields accross forms

Status
Not open for further replies.

varean

Technical User
Apr 9, 2001
17
US
I'm using this command to pass fields "case number" and "victim id" to "additional victim" form from "clients" form, I need to pass 2 more fields from clients: "accepted services date" and "accepted service". What would be the correct syntax ?

Private Sub Add_Add_Victim_Click()
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Set myfrm = Screen.ActiveForm
DoCmd.OpenForm "additional Victim", , , "[case number]=forms!client!casenumber and victim=2"
End Sub
 
When you know how to pass 2 fields already, I am not sure where you are finding it difficult to pass another 2 fields

You could add and pass another 2 fields to the already exiting code

DoCmd.OpenForm "additional Victim", , , "[case number]=forms!client!casenumber and victim=2 and
[accepted_services_date]=forms!client!accepted_service_date and [accepted_service]=forms!client!accepted_service"

You may have to change the field names though
 
I don't know what's wrong but when I have this code, the secondary form does not show any fields :
DoCmd.OpenForm "additional Victim", , , "[case number]=forms!client!casenumber and victim=2 and [accepted services date]=forms!client!acceptedservicesdate"

When I have it without the accepted services field it works.
DoCmd.OpenForm "additional Victim", , , "[case number]=forms!client!casenumber and victim=2"

thanks!
 
Possible test cases would be:

The field `[accepted services date]` must be present in the `additional Victim` table as spelt in the code.

A Textbox forms!client!acceptedservicesdate must be present in the `client` form as spelt in the code.

The data type of `victim` field has to be integer

Atleast one row must be present in `additional Victim` table which matches all 3 criteria specified below:
[case number]=forms!client!casenumber
victim=2
[accepted services date]=forms!client!acceptedservicesdate

If there are no rows which satisfies all the above 3 conditions, your code will return blank and you may not see the desired form

From your previous post it seems 2 conditions are satisifed
ie., there is atleast one row in your `additional Victim` table which has
[case number]=forms!client!casenumber
victim=2

Now Check if that row has [accepted services date]=forms!client!acceptedservicesdate

Your code works only if you find above matching values

So before executing the DoCmd.OpenForm... make sure the WHERE Condition values you are passing are valid and matching records are available in table so that WHERE condition is satisfied.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top