I am needing to use the same Code for multiple situations but I can not figure out one part. Here is a example:
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'LETS SEE WHICH CHECKOUT FORM IS OPEN SO WE CAN FILL IT OUT PROPERLY'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Dim CheckoutFormName As String Dim Receipt As StringIf CurrentProject.AllForms("frmNewOrdersGuestCheckout").IsLoaded = True Then ' Guest Checkout Form is OpenCheckoutFormName = "frmNewOrdersGuestCheckout"Receipt = "RptqryGuestCheckoutReceipt"End IfIf CurrentProject.AllForms("frmNewOrder").IsLoaded = True Then ' Customer with account Form is OpenCheckoutFormName = "frmNewOrder"Receipt = "RptqryCheckoutReceipt"End IfForms!CheckoutFormName!OrderStatusID = "7"
Now for the line Forms!CheckoutFormName!OrderStatusID = "7" how would I set it up to get Access to find and accept the the String (CheckoutFormName) as a form?
I don't know what the calling point of your code is. But note that you can pass a form object to your code, to ensure that you always have the right reference.
E.g.
Call SomeCode(me)Public sub SomeCode(frm as form) 'Some other stuff might go here frm!OrderStatusID!value=7end Sub
Anders Can you please explain better. The form that is open sometimes is different (Varying). So how can calling to another sub be beneficial?
Wouldn't I have to have a varying call if that makes sense.....
Anders Ebro (Microsoft MVP)
What is the starting point of your code? What triggers it? What scenario are you trying to solve. Then I could better put the explanation of the technique in context of your situation.
This is not a very useful example, but gives you an idea of what Anders is talking about.
Dale
Dustin Stanley
ASKER
Ok I still don't understand.
In my example:
Dim CheckoutFormName As String Dim Receipt As StringIf CurrentProject.AllForms("frmNewOrdersGuestCheckout").IsLoaded = True Then ' Guest Checkout Form is OpenCheckoutFormName = "frmNewOrdersGuestCheckout"Receipt = "RptqryGuestCheckoutReceipt"End IfIf CurrentProject.AllForms("frmNewOrder").IsLoaded = True Then ' Customer with account Form is OpenCheckoutFormName = "frmNewOrder"Receipt = "RptqryCheckoutReceipt"End IfForms!CheckoutFormName!OrderStatusID = "7"
E.g.
Open in new window