Solved Listbox Row Double_Click Criteria Not Work (1 Viewer)

smtazulislam

Member
Local time
Today, 23:09
Joined
Mar 27, 2020
Messages
806
Hello,
I have a listbox what is name "lstPassportExpire". I want to double_click to open FORM "frmEmployeeEdit" by criteria PassportID

my Listbox Query is
Code:
SELECT tblPassport.PassportID, tblPassport.EmployeeID, tblEmployee.Country, tblPassport.PassportNo, tblPassport.ExpiredDate
FROM tblEmployee INNER JOIN tblPassport ON tblEmployee.EmployeeID = tblPassport.EmployeeID
WHERE (((tblEmployee.StatusID)=1) AND ((tblEmployee.IdentityType)="Iqama"))
ORDER BY tblPassport.ExpiredDate;
I try to this code:
Code:
Private Sub lstPassportExpire_DblClick(Cancel As Integer)
 
Dim StrCriteria As String

'open the form
DoCmd.OpenForm FormName:="frmEmployeeEdit"

' set reference to the form
Set TabCtlFrm = [Forms]![frmEmployeeEdit]

' loop through all Pages in TabGeneral tab control
For Each TabCtlPg In TabCtlFrm!TabCtlEdit.Pages


    If TabCtlPg.Name = "EmployeeIdentity_Page" Then
        ' set focus to this page
        StrCriteria = "PassportID = " & Me.lstPassportExpire.Column(0)
        TabCtlPg.SetFocus
    End If
Next
Set TabCtlFrm = Nothing
Debug.Print StrCriteria

End Sub
This code open only FORM "frmEmployeeEdit" but not same selected passportID open.
Any help will be appreciate.
Thank you.
 

moke123

AWF VIP
Local time
Today, 16:09
Joined
Jan 11, 2013
Messages
3,919
Code:
'open the form
StrCriteria = "PassportID = " & Me.lstPassportExpire.Column(0)

DoCmd.OpenForm FormName:="frmEmployeeEdit",,,StrCriteria

you can just set focus to the tab page without iterating through them
 

smtazulislam

Member
Local time
Today, 23:09
Joined
Mar 27, 2020
Messages
806
Code:
'open the form
StrCriteria = "PassportID = " & Me.lstPassportExpire.Column(0)

DoCmd.OpenForm FormName:="frmEmployeeEdit",,,StrCriteria

you can just set focus to the tab page without iterating through them
its not work

I also try to
Code:
DoCmd.OpenForm "frmEmployeeEdit", acNormal, , _
"[employeeID] = " & Me.lstPassportExpire.Column(0), , , "lstPassportExpire"
its open and work. but Tabbed index not focus.

/edit
What can I do for setFocus in this tab page ?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 16:09
Joined
May 21, 2018
Messages
8,527
Simply set the value of the tab control after calling the form to open. Tabs are 0 indexed. To set focus to the 3rd tab
DoCmd.OpenForm "frmEmployeeEdit", acNormal, , _
"[employeeID] = " & Me.lstPassportExpire.Column(0), , , "lstPassportExpire"
forms("frmEmployeeEdit").NameOfTabControl.value = 2
 

smtazulislam

Member
Local time
Today, 23:09
Joined
Mar 27, 2020
Messages
806
Simply set the value of the tab control after calling the form to open. Tabs are 0 indexed. To set focus to the 3rd tab
DoCmd.OpenForm "frmEmployeeEdit", acNormal, , _
"[employeeID] = " & Me.lstPassportExpire.Column(0), , , "lstPassportExpire"
forms("frmEmployeeEdit").NameOfTabControl.value = 2
Oh nice, great work ! Mr. Majp
Thank you so much
 

Users who are viewing this thread

Top Bottom