Args (2) to pass data to unbound combo boxes

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 G., i think i made a valid Call to the Sub. It is a member of the same form (not outside).
 
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?
 
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

Back
Top Bottom