Args (2) to pass data to unbound combo boxes (1 Viewer)

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 05:17
Joined
Jul 9, 2003
Messages
16,287
Information about Pop-up, Modal, and Dialog Forms from theDBguy HERE:-


I treat Modal and dialogue incorrectly as one in the same, however there are subtle differences you should be aware of. The above link should help clarify things.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 21:17
Joined
Aug 30, 2003
Messages
36,127
I believe that the o/p expects the form to go to the record for that account and entry no, just because the two combos are populated from openargs.

You could be right. The OpenArgs code appears to be doing what it's supposed to.
 

YAM

New member
Local time
Today, 09:47
Joined
Jul 15, 2020
Messages
26
Thanks uncle Gizmo for your kind help.


It will be working fine some points you mentioned i need to explore how and what need to be mentioned, little things need to change.

However, I will be using this from (frmEditBankEntry) to open many form based on each check box selected like i have frmBankTransferEntry for Bank Transfer Check box, frmDepositsEntry, frmChequeEntry, frmStandingOrdersEntry etc, for which i need to modify it to accommodate all these forms opening to be treated in same way because the field name is same in all forms, which is cboSelectBank for BankAccount and cboEntryNo for EntryNo.

i could put some code like as you mentioned on command button

Code:
If Me.EntryType = "Bank Transfer" Then
    DoCmd.OpenForm strFrmName, acNormal, , , acFormEdit, , BankAccount & ";" & EntryNo
    
    With Forms(strFrmName)
    '.prpClientID = Me.ClientID
    .EditEntry
    .Modal = True
    '.Caption = "I CAN CHANGE THE CAPTION"
    End With

Else
    If Me.EntryType = "Cheque" Then
    DoCmd.OpenForm strFrmName, acNormal, , , acFormEdit, , BankAccount & ";" & EntryNo
    
    With Forms(strFrmName)
    '.prpClientID = Me.ClientID
    .fcboEntryNoRequery
    .Modal = True
    '.Caption = "I CAN CHANGE THE CAPTION"
    End With

While opening rest of the form it need some sort of accommodation and linking of fields in public function that you suggest for which i dont know how to add i did try something like mentioned below but it turns little bit messy need to do it properly.

Code:
Public Function EditEntry() As String

Dim conAppName As String
Dim strSubName As String
Dim strModuleName As String
Dim ChequeEntry As String
Dim BankTransferEntry As String
Dim DepositEntryEntry As String
Dim StandingOrderEntry As String
Dim CashWithdrawals As String
Dim ATMTransactions As String

ChequeEntry = "frmChequeEntry"
BankTransferEntry = "frmBankTransferEntry"
DepositEntry = "frmDepositEntry"
StandingOrderEntry = "frmStandingOrderEntry"
CashWithdrawals = "frmCashwithdrawals"
ATMTransactions = "frmATMtransactions"

If Forms(BankTransferEntry).CurrentView <> conDesignView Then


conAppName = (s)



strSubName = EditEntryLookup
strModuleName = Functions
'strModuleName = "Module - basModuleName"'

On Error GoTo Error_Handler

'Select records based on Entry No
Me.Recordset.FindFirst "EntryNo = " & cboEntryNo
Me.cboEntryNo.Requery
Me.Refresh

        If Me.Void = True Then
            MsgBox "This Entry and its underline transactions are Voided before !"
        End If


Exit_ErrorHandler:
    
    Exit Function

Error_Handler:  'Version - 1a
    Dim strErrFrom As String
    Dim strErrInfo As String
        
        strErrFrom = "Error From:-" & vbCrLf & strModuleName & vbCrLf & "Subroutine >>>>>>> " & strSubName
        strErrInfo = "" & vbCrLf & "Error Number >>>>> " & Err.Number & vbCrLf & "Error Descscription:-" & vbCrLf & Err.Description
            
            Select Case Err.Number
                Case 0.123 'When Required, Replace Place Holder (0.123) with an Error Number
                    MsgBox "Error produced by Place Holder please check your code!" & vbCrLf & vbCrLf & strErrFrom & strErrInfo, , conAppName
                Case Else
                    MsgBox "Case Else Error" & vbCrLf & vbCrLf & strErrFrom & strErrInfo, , conAppName
            End Select
        Resume Exit_ErrorHandler

End Function      'EditEntry
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 05:17
Joined
Jul 9, 2003
Messages
16,287
I think you want something like this:- See Attached --- It contains Code from one of my products:-

Nifty Option Group Label Color Changer - MS Access HERE:-

You can download "Nifty Option Group Label Color Changer" for free. Contact me for details...
 

Attachments

  • RunPubFunctionThenSetModal_2a.zip
    129.8 KB · Views: 98
Last edited:
  • Like
Reactions: YAM

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 05:17
Joined
Jul 9, 2003
Messages
16,287
I will be using this from (frmEditBankEntry) to open many form based on each check box selected like i have frmBankTransferEntry for Bank Transfer Check box, frmDepositsEntry, frmChequeEntry, frmStandingOrdersEntry etc,

I can see that you are planning to open a several different forms. This is generally a bad idea. My guess is that the essential nature of each of the forms you plan to open will be the same/similar. I if that's the case you are much better off having one form and modifying it when you open it to look different. You could give it a different title, you could expose/hide different controls to guide the user through the steps they need to take. The code example I provided for opening a form lends itself to this process. The code block makes it relatively simple to modify the form by using code like this:-

Code:
   DoCmd.OpenForm strFrmName, acNormal, , , acFormEdit, , BankAccount & ";" & EntryNo
    
    With Forms(strFrmName)
    '.prpClientID = Me.ClientID
    .EditEntry
    .Modal = True
    '.Caption = "I CAN CHANGE THE CAPTION"
    End With
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 05:17
Joined
Jul 9, 2003
Messages
16,287
Generally the code would take the form of a Case Statement. You would then pass into the case statement the number of the check-box selected via the option group afterupdate event. Each Select Case would open the same form, but set different elements of the form. You could change its RecordSource for instance, you can change its title, you could hide certain controls and exposes others.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:17
Joined
May 7, 2009
Messages
19,247
see the changes i made on the Load event of the form.
 

Attachments

  • Test (1).zip
    96.6 KB · Views: 108

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 05:17
Joined
Jul 9, 2003
Messages
16,287
see the changes i made on the Load event of the form.

Thank you for that arnellgp I have learnt something very useful! My understanding is that you should NEVER Call a Controls Event directly. If it became necessary to call the code residing in a control event, then you would separate it out into a separate function/subroutine and call that from both the control and from whatever other process you needed to.

I discovered when dealing with a "Modal Form", it doesn't work, the form locks you down and you just can't do it. I did know that you could set the properties of any of the controls on the form, you can enable/disable lock/unlock and do many other operations through load event. However I hadn't put two and two together and realised that if I called the after update event of a control, then the code in that Event stub would run. Thank you for that! I have learnt something very useful and I shall be breaking this written/unwritten rule frequently in the future!
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:17
Joined
May 7, 2009
Messages
19,247
Uncle G., i think i made a valid Call to the Sub. It is a member of the same form (not outside).
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 05:17
Joined
Jul 9, 2003
Messages
16,287
Uncle G., i think i made a valid Call to the Sub. It is a member of the same form (not outside).

Yes I totally agree.

You have demonstrated that there is a better way to do things which I will be using in future projects.
 

Gasman

Enthusiastic Amateur
Local time
Today, 05:17
Joined
Sep 21, 2011
Messages
14,350
Thank you for that arnellgp I have learnt something very useful! My understanding is that you should NEVER Call a Controls Event directly. If it became necessary to call the code residing in a control event, then you would separate it out into a separate function/subroutine and call that from both the control and from whatever other process you needed to.
TBH, this is something I have I have done in the past. If I have some code already written in an event in the same object and I needed to execute that, I would still call the event. The chances are it is going to be unique to that object?, if not then I would consider a sub in a module if used elsewhere?
 

YAM

New member
Local time
Today, 09:47
Joined
Jul 15, 2020
Messages
26
Thank you so much for you all, i feel wealthy in knowledge with your excellent advise and support...GOD Bless.
 

Users who are viewing this thread

Top Bottom