On Current for embedded forms

andy_dyer

Registered User.
Local time
Today, 20:29
Joined
Jul 2, 2003
Messages
806
This may be blindingly obvious... but after some hours wrestling with this I may be blind to the obvious...

I have an embedded form (frmInvoice) within frmProject

I have various visible and non visble settings on current for frmInvoice which work a treat when opened isolation...

When opened from within frmProject everything is visible... I figured this was because these visible settings weren't within the frmProject On Current section of code...

I copied and pasted the code across but was then faced with the database not recognising the fields within frmInvoice on ther frmProject On Current...

I then changed the way the fields were addressed from Me.chkSent to Forms!frmInvoice!Me.chkSent which only seems to have changed my error message and not got rid of it...

It now can't find frmInvoice referred to...

Is there something obvious I've missed??

Many thanks,
 
Sounds like you aren't referencing the subform controls correctly. Should be something like:

forms!frmMain!subFormControlName.form!subformControlName.SomePropertyName
 
I think I've followed that right but i still get a message that it can't find frmInvoice

This is my first line:

Code:
If Me.frminvoice.Form!Me.chkSent And Me.frminvoice.Form!Me.chkPaid = False Then

What's going wrong??
 
Sorry, You're errors are blatant. If you can't follow the help in Pauls link then I surely can't help you anymore - :)
 
Make sure that frminvoice is the name of the subform control (not the actual form), and you don't want the "Me." in the control part.
 
Make sure that frminvoice is the name of the subform control (not the actual form), and you don't want the "Me." in the control part.

Thank you for your help - i just don't understand what a subform control is... I've pasted inserted a form inside another form so have two forms frmProject and frmInvoice...

I really am sorry if I'm missing something blatently obvious... I'm just understanding the terminology...
 
I did it...

I opened the properties of the embedded form and notice the name was different to the form name - so that is clearly what I was missing...

Then I just couldn't understand why i would take the me. out from in front of the field when it is in there for practically anything else!!

Code:
If Me!Invoice.Form!chkSent And Me!Invoice.Form!chkPaid = False Then

This code now works - so thank you for your patience... :D
 
Re: UPDATED On Current for embedded forms

Ok slightly new but related problem - wonder if I'm missing something obvious again...

When I add a new record within my embedded form it retains the previous record's visibility settings...

What i want it to do on clicking the next record button on the navigator to check the check box settings and display accordingly...

Code:
If Not Me!Invoice.Form.NewRecord And Me!Invoice.Form!chkSent = False And Me!Invoice.Form!chkPaid = False Then
Me!Invoice.Form!cmdPlanned.Visible = True
Me!Invoice.Form!cmdClearPlanned.Visible = True
Me!Invoice.Form![Planned Invoice Date].Visible = True
Me!Invoice.Form!cmdActual.Visible = False
Me!Invoice.Form!cmdClearActual.Visible = False
Me!Invoice.Form![Actual Invoice Date].Visible = False
Me!Invoice.Form![invoice number].Visible = False
Me!Invoice.Form!chkPaid.Visible = False
Me!Invoice.Form![Payment Received Date].Visible = False
Me!Invoice.Form!cmdPayment.Visible = False
Me!Invoice.Form!cmdClearPayment.Visible = False
End If

I've even tried adding this code to make it explicit (which wasn't required in a previus database with lots of these visibility settings...)

Code:
If Me!Invoice.Form.NewRecord Then
Me!Invoice.Form!cmdPlanned.Visible = True
Me!Invoice.Form!cmdClearPlanned.Visible = True
Me!Invoice.Form![Planned Invoice Date].Visible = True
Me!Invoice.Form!cmdActual.Visible = False
Me!Invoice.Form!cmdClearActual.Visible = False
Me!Invoice.Form![Actual Invoice Date].Visible = False
Me!Invoice.Form![invoice number].Visible = False
Me!Invoice.Form!chkPaid.Visible = False
Me!Invoice.Form![Payment Received Date].Visible = False
Me!Invoice.Form!cmdPayment.Visible = False
Me!Invoice.Form!cmdClearPayment.Visible = False
End If

Any ideas what i'm missing??
 
Where is that code? I would expect it in the current event of the subform, but the code indicates it's in the main form somewhere.
 
Where is that code? I would expect it in the current event of the subform, but the code indicates it's in the main form somewhere.

Hi,

Similar code is in the on current in the subform, but that didn't work when the form was embedded so i changed the references and added it also to the on current on the main form - so it's kind of in there twice and still doesn't work...
 
Try the current event of the subform with code like:

Me.cmdPlanned.Visible = True
 
Subform On Current

Code:
Private Sub Form_Current()
If Not Me.NewRecord And Me.chkSent = False And Me.chkPaid = False Then
Me.cmdPlanned.Visible = True
Me.cmdClearPlanned.Visible = True
Me.Planned_Invoice_Date.Visible = True
Me.cmdActual.Visible = False
Me.cmdClearActual.Visible = False
Me.[Actual Invoice Date].Visible = False
Me.[invoice number].Visible = False
Me.chkPaid.Visible = False
Me.Payment_Received_Date.Visible = False
Me.cmdPayment.Visible = False
Me.cmdClearPayment.Visible = False
End If

Main Form On Current

Code:
Private Sub Form_Current()
If Not Me!Invoice.Form.NewRecord And Me!Invoice.Form!chkSent = False And Me!Invoice.Form!chkPaid = False Then
Me!Invoice.Form!cmdPlanned.Visible = True
Me!Invoice.Form!cmdClearPlanned.Visible = True
Me!Invoice.Form![Planned Invoice Date].Visible = True
Me!Invoice.Form!cmdActual.Visible = False
Me!Invoice.Form!cmdClearActual.Visible = False
Me!Invoice.Form![Actual Invoice Date].Visible = False
Me!Invoice.Form![invoice number].Visible = False
Me!Invoice.Form!chkPaid.Visible = False
Me!Invoice.Form![Payment Received Date].Visible = False
Me!Invoice.Form!cmdPayment.Visible = False
Me!Invoice.Form!cmdClearPayment.Visible = False
End If
 
My code is still as above which was posted to show that this still isn't working despite me following pbaldy's suggestion...

Any further ideas???
 
Oh, you need an Else clause to set the controls back to how you want them for records that don't meet those criteria.
 
Oh, you need an Else clause to set the controls back to how you want them for records that don't meet those criteria.

I did have one big If statement with lots of else clauses... I then changed it to lots of if and end if statements... I had the same problem both ways - I'm not sure which one is technically correct but neither seem to work still... :(

Any more ideas - sorry for being a pain!
 
Can you post the db, or a sample that shows the problem?
 
Here you go...

Click on Joe Bloggs as the client and then view existing...

If you then go to the invoices tab click the edit form button to enable you to change things then click the new record button on the embedded form it will keep the same fields visible as before...

If you click and unclick the invoice sent check box it will show what it should for a new record...

Hope that helps...
 

Attachments

Refresh my memory on exactly what the problem is. I see various fields disappearing and reappearing as I scroll through records on frmInvoice, so it would appear that the code is working.
 
On a new record accessed by clicking next record on the navigation buttons at the end of the existing set, it remembers what the last visible and invisible fields were and doesn't refresh back to the standard if the invoice sent checkbox isn't ticked...

If you check and uncheck that invoice sent box it works fine but I'm trying to get it to do this automatically which i thought the On Current should do...

:confused:
 

Users who are viewing this thread

Back
Top Bottom