Opening forms (that is related to same record)

t3nchi

Registered User.
Local time
Today, 13:22
Joined
Sep 28, 2005
Messages
79
I have 3 forms.

I open the very first one (main form). From there, I wrote a little VBA in the 'Add Record' button that if a certain checkbox in that form wasn't checked when I click 'Add Record', it would open up the 2nd form.

The problem is, when I open up the 2nd form and enter info, the info is all put into a new record.

I want the 2nd form's info to go into the same record as the main form. It's all related.

How do I do that?

Note:I built the 2nd and 3rd form from queries that had parameter querying in them...the parameters are frmo the main form.
 
Redirect your Data fields in the form properties

I believe You will have to open up the properties of the 2nd form and on each of the Fields that you are entering data into you will go to the Data tab. you will then have to change the Record Source for that field. Hope this helps...
 
Monstermechanic said:
I believe You will have to open up the properties of the 2nd form and on each of the Fields that you are entering data into you will go to the Data tab. you will then have to change the Record Source for that field. Hope this helps...

I looked at the record source of my 2nd form. It is the query for which I have parameter querying set up. (year,company name parameters....which come from the first form)
 
Is the data for your forms coming from the same table? If they are then this little sample may help you.

When you open the db the "Company form" will appear, click the button on the form and you will see that another form opens which has the companies name in the caption and data that relates to the company (address etc).

With both of these forms open you can use the > (Arrow Key) to scroll through the records. You will notice that the second form syncs with the first.

If you want to create a new record, close the second form, add a new company name and then click the button, you will see that the second form opens with the name of the company that you just added appearing in the caption of the second form. Just go ahead and add data to the second form.

If this is not what you want it may help with some ideas.
 
Last edited:
ansentry said:
Is the data for your forms coming from the same table? If they are then this little sample may help you.

When you open the db the "Company form" will appear, click the button on the form and you will see that another form opens which has the companies name in the caption and data that relates to the company (address etc).

With both of these forms open you can use the > (Arrow Key) to scroll through the records. You will notice that the second form syncs with the first.

If you want to create a new record, close the second form, add a new company name and then click the button, you will see that the second form opens with the name of the company that you just added appearing in the caption of the second form. Just go ahead and add data to the second form.

If this is not what you want it may help with some ideas.

Yes they are from the same table. I'm going to take a look at your sample now.Thanks.
 
I need to revive this topic because I still haven't solved it.

I have a form in Add mode. I enter date in the form. I want to click 'Add Record' and want a form (that has other fields related to SAME record from first form) to pop up in edit mode. These fields are empty.

Ansentry's code didn't seem to help because everytime the new form is opened, it generates a new ID. I want the SAME ID and record.

Maybe I need to do it subform style...But ideas/suggestions first?
 
Don't quite sure what you want?? Ansentry's cade is corrected. If you enter a new record in the company name "ABC" then you click on company addresse details, a form pop up with an ID 4 where the main form as also an ID 4. So, what is the problem??

Le
 
le888 said:
Don't quite sure what you want?? Ansentry's cade is corrected. If you enter a new record in the company name "ABC" then you click on company addresse details, a form pop up with an ID 4 where the main form as also an ID 4. So, what is the problem??

Le

That's what I'm trying to figure out.
 
BTW, his forms deal with 1 table.

I have three forms. Each comes from a dif query. All queries are querying the same table however. Do I need some sort of special query (joint queries or something)
 
t3nchi said:
BTW, his forms deal with 1 table.

I have three forms. Each comes from a dif query. All queries are querying the same table however. Do I need some sort of special query (joint queries or something)

Can you post your database??

Le
 
le888 said:
Can you post your database??

Le

Too big to post. But i found out a couple more things.

Anytime the form is in "add mode", the ID doesn't match. The 2nd form will start a new ID.

Only when it's in "edit mode", then the new form will have the same ID.
 
Ansentry's code didn't seem to help because everytime the new form is opened, it generates a new ID. I want the SAME ID and record.
My codes does not do this, it opens at the same record (CustomerID).

BTW, his forms deal with 1 table.

I have three forms. Each comes from a dif query. All queries are querying the same table however. Do I need some sort of special query (joint queries or something)
I thought that you were using 2 forms. If each form has a query as data source and that query is based on the same table then your queries should not be a problem.

Anytime the form is in "add mode", the ID doesn't match. The 2nd form will start a new ID.

Only when it's in "edit mode", then the new form will have the same ID.
What is add mode & edit mode?
 
Last edited:
ansentry said:
My codes does not do this, it opens at the same record (CustomerID).


How many tables are you using for the three forms?


What is add mode & edit mode?

Hi ansentry. Only 1 table for all three forms. Just dif queries picking up dif fields for different forms.

Add mode = form opens completely blank (so you can input new record)
Edit mode = form opens with a record displayed...you can scroll through them

And yea I figured my queries wouldn't be a problem.

1) open blank form
2) fill out some info
3) if certain field is left blank, want to set up button so when i click it, it checks that field. If field = blank, then 2nd form opens up (not to add another record but to edit the same one, just filling up more fields for that same record)

What's the code to open a form in edit mode.
 
Last edited:
I don't know about your code, but mine does not open the second form (FrmAddresses) to a blank record if the first form (frmCompany) is on newRecord (or as you refer to it as add mode). The following code prevents that:

Code:
If IsNull(Me!CompanyID) Or Me!CompanyID = "" Then
    strMsg = "The Current form does not have any Data"
    strTitle = "Details Error!!"
    intStyle = vbOKOnly
MsgBox strMsg, intStyle, strTitle

I cannot understand your problem, is it with my code or your code?

If it is with your code then post it here and someone may have a look at it. Does the 3rd form have any relevance to your problem?
 
ansentry said:
I don't know about your code, but mine does not open the second form (FrmAddresses) to a blank record if the first form (frmCompany) is on newRecord (or as you refer to it as add mode). The following code prevents that:

Code:
If IsNull(Me!CompanyID) Or Me!CompanyID = "" Then
    strMsg = "The Current form does not have any Data"
    strTitle = "Details Error!!"
    intStyle = vbOKOnly
MsgBox strMsg, intStyle, strTitle

I cannot understand your problem, is it with my code or your code?

If it is with your code then post it here and someone may have a look at it. Does the 3rd form have any relevance to your problem?

I think that may be what I'm missing. Let me try it out. Yea I saw that but didn't think it had anything to do with my problem.
 
ansentry said:
What form? - Mine or yours?

I just got my arse handed to me. That code you put up, I misinterpreted its use so I didn't put it in. Now I know that THAT was what solves my problem. oops... thanks man!

I had just created the Command button and didn't write the extra code in.
 

Users who are viewing this thread

Back
Top Bottom