Forum Discussion
It sounds like the issue might be related to how the combo box in the second form is populated with data. Here are a few steps you can take to troubleshoot and fix the issue:
- Check Data Source: Ensure that the combo box in the second form is linked to the correct data source in your Excel sheet. Double-check the range of cells or named range that you have specified as the data source for the combo box.
- Verify Data Range: Make sure that the data range specified for the combo box includes the correct data and that there are no empty cells or errors within the range.
- Refresh Data: If the data in your Excel sheet has been updated since you opened the second form, you may need to refresh the data source for the combo box. You can do this programmatically using VBA code or manually by closing and reopening the form.
- Ensure Visibility: Check the properties of the combo box in the second form to ensure that it is set to be visible. Sometimes, if the visibility property is accidentally set to false, the combo box may not display any data.
- Debugging: Use VBA debugging tools to check if there are any errors occurring when populating the combo box with data. You can set breakpoints in your code and step through it to see if there are any issues.
- Recreate Combo Box: If all else fails, try deleting the combo box in the second form and recreating it from scratch. Sometimes, there may be hidden issues with the combo box properties that are difficult to identify.
If you're still experiencing issues after trying these steps, please provide more details about how the combo box is populated and any relevant VBA code that you're using. This will help in providing a more targeted solution to the problem. The text was created with the help of AI
My answers are voluntary and without guarantee!
Hope this will help you.
Was the answer useful? Mark as best response and like it!
This will help all forum participants.
NikolinoDE Thank you for replying. I have tried all the above. Still no luck. I was wondering if it has to do with a bug in software? In that you can't have 2 forms open at once? The strange thing is, I tested the combo box by moving it to the first form, and it works fine. when I move it to the second form, I don't see the data. Any other ideas? Thanks.
- djclementsMar 05, 2024Bronze Contributor
guitar713 Having two userforms open at once shouldn't be a problem. Glitches can occur, though, especially with Excel for MS365. How exactly are you populating the combo box? Did you hard code the worksheet range directly in the RowSource property of the combo box? Did you define a name for the worksheet range, as shown in the example below?
Alternatively, you can also try leaving the RowSource property blank, then populate it on the fly in the UserForm_Initialize procedure. For example:
Private Sub UserForm_Initialize() Me.ComboBox1.RowSource = "lstStatus" End Sub
Or, by looping through the items in the range:
Private Sub UserForm_Initialize() Dim rg As Range, i As Long Set rg = Range("lstStatus") For i = 1 To rg.Rows.Count Me.ComboBox1.AddItem rg.Cells(i, 1).Value Next i End Sub
These are just a few basic examples. I've tested them all with two simple userforms (shown in the screenshot above) and did not have any issues. If you are still unable to get it to work, please consider sharing more details, such as the code you are using in the each of the userforms, especially the code that opens the second userform, as well as any code currently being used in the UserForm_Initialize procedure of the second userform.
- guitar713Mar 05, 2024Brass ContributorSo the way I am calling the second form is to double click on a text box. I use the following code:
----------------------------
Private Sub txtCURRENTPeoplesoft_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
frmPeopleSoft.Show vbModeless
frmPeopleSoft.Enabled = True
End Sub
----------------------------------
But when I put the code that you recommended into the form 2 as follows:
----------------------------------
Private Sub UserForm_Initialize()
frmPeopleSoft.Enabled = True
Me.ComboBox1.RowSource = "Table3"
End Sub
-----------------------------
then I run my code, I get the following error
Run-time error '380':
Could not set the RowSource property. Invalid property value.
Then when I click on the debug tool, it goes to
Private Sub txtCURRENTPeoplesoft_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
frmPeopleSoft.Show vbModeless ---- this one is hightlighted as errored???
If you can follow my logic, this is what is happening.
thanks.- guitar713Mar 05, 2024Brass ContributorI have tried to fill in the "RowSource" property as well in the properties dialog....
That did not work either...