Userform Listbox Double Click

gilly01625

New Member
Joined
Nov 8, 2024
Messages
38
Office Version
  1. Prefer Not To Say
Platform
  1. Windows
Hey,

I have an error on a userform I am developing - dropbox link to file below.

On frmSummary, the user is able to select between two countries, 'UK' and 'AUS', at the top of the form which in result displays listboxes corresponding to the country selected at the bottom of the form. A Multipage is displayed with said listboxes across two pages relating to the selected country, 'UKWork' and 'UKSummary' or 'AUSWork' and 'AUSSummary'. The user is able to double click on an entry (row) within the listbox ('UKSummary' or 'AUSSummary') and have the data presented on the userform in corresponding text boxes. I have this feature on the majority of the other userforms on this workbook and it works as expected, however it does not work for this userform. 'UKSummary' is working as expected, but 'AUSSummary' is not and I am unsure why.

Can anyone help please?

Dropbox link below.

DropBox

Thanks!
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
but 'AUSSummary' is not and I am unsure why.

At the end of the double click event of the "lstAUSSummaryDatabase" listbox you have these lines:
VBA Code:
    Me.txtCountryHIDDEN = Me.lstAUSSummaryDatabase.List(Me.lstAUSSummaryDatabase.ListIndex, 168)
    If Me.txtCountryHIDDEN.Value = "UK" Then
        Me.chkUK.Value = True
        Me.chkAUS.Value = False
    End If
    If Me.txtCountryHIDDEN.Value = "AUS" Then
        Me.chkAUS.Value = True
        Me.chkUK.Value = False
    End If
I honestly don't know why you have them, because if you chose Aus, then the data belongs to Aus, so there is no point in validating it.

But the problem is in the "AUSSummary" sheet, in the last column you have "UK", you should have "AUS".
1737041107212.png

When you press double clic, Check the content of that column in the listbox:

If Me.txtCountryHIDDEN.Value = "UK" Then
Me.chkUK.Value = True
Me.chkAUS.Value = False
End If

If it is "UK" then Me.chkUK.Value = True, That triggers the Private Sub chkUK_Click() event and clears everything.

If you change the data in the "AUSSummary" sheet and put "AUS", the code works.

😅
 
Upvote 0
Solution
At the end of the double click event of the "lstAUSSummaryDatabase" listbox you have these lines:
VBA Code:
    Me.txtCountryHIDDEN = Me.lstAUSSummaryDatabase.List(Me.lstAUSSummaryDatabase.ListIndex, 168)
    If Me.txtCountryHIDDEN.Value = "UK" Then
        Me.chkUK.Value = True
        Me.chkAUS.Value = False
    End If
    If Me.txtCountryHIDDEN.Value = "AUS" Then
        Me.chkAUS.Value = True
        Me.chkUK.Value = False
    End If
I honestly don't know why you have them, because if you chose Aus, then the data belongs to Aus, so there is no point in validating it.

But the problem is in the "AUSSummary" sheet, in the last column you have "UK", you should have "AUS".

When you press double clic, Check the content of that column in the listbox:

If Me.txtCountryHIDDEN.Value = "UK" Then
Me.chkUK.Value = True
Me.chkAUS.Value = False
End If

If it is "UK" then Me.chkUK.Value = True, That triggers the Private Sub chkUK_Click() event and clears everything.

If you change the data in the "AUSSummary" sheet and put "AUS", the code works.

😅
Thank you so much!
 
Upvote 0

Forum statistics

Threads
1,225,617
Messages
6,186,017
Members
453,334
Latest member
Prakash Jha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top