Update a combo box

NDMDRB

Board Regular
Joined
Jun 20, 2016
Messages
164
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I have the following code on my userform "frmPOS" to check if any entered client name if exist or not, if so, get the ID and mobile to txtID and txtMobile
If not, pop up msg that this is not exist and if I need to add a new client, if so, show the form "frmNewClient" and add new client

This code works very well, but what I need, once I add a new client after the above procedure, get back to the main form with updated clients list (cmbName to updated with the new client name)

I've tried to unload the form and reopen it but non of the codes works well, (The notes included in the code is what I've tried)
and I tried to put "frmPOS.show" after I add a new client but getting the same result, non of the codes works well


Code:
Dim UfDic As Object

Private Sub cmbName_Change()   With Me.cmbName
      If UfDic.exists(.Value) Then
         Me.txtID.Value = UfDic.Item(.Value)(0)
         Me.txtMobile.Value = UfDic.Item(.Value)(1)
      Else
         If MsgBox(.Value & "!!!" & vbCrLf & vbCrLf & "The above client name is not Exist" & vbCrLf & vbCrLf & _
         "Do you wanna add a new client?", vbYesNo) = vbYes Then
'Unload Me            
frmNewClient.show
'frmPOS.show
            Else
            Me.cmbName = "Cash Client"
         End If
      End If
   End With
End Sub

Private Sub txtMobile_Change()
Call cmbName_Change
End Sub

Private Sub txtID_Change()
Call cmbName_Change
End Sub

Private Sub UserForm_Initialize()
Dim Cl As Range
   Set UfDic = CreateObject("scripting.dictionary")
   UfDic.CompareMode = 1
   For Each Cl In Sheet5.Range("Client_Details").Columns(2).Rows
      If Not UfDic.exists(Cl.Value) Then UfDic.Add Cl.Value, Array(Cl.Offset(, -1).Value, Cl.Offset(, 1).Value)
   Next Cl
   Me.cmbName.List = UfDic.keys
End Sub
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Show frmNewClient then unload frmPOS and move frmPOS.show to a sub in frmNewClient
 
Upvote 0
Thanks NoSparks, but I did the same as you said, it works and the frmPOS shows again, but non of the subroutines works
es: once I run the subroutine above and return back to frmPOS, If I choose any client name, the txtID will be empty, also all the subroutines will not get the needed values

But if I show the frmNewClient from a module, and run the frmPOS runs from frmNewClient, it works very well
 
Upvote 0
I did the same as you said, it works and the frmPOS shows again, but non of the subroutines works
did they ever work ?
starting frmPOS over completely anew it will operate the same as it did before.
 
Last edited:
Upvote 0
If I start frmPOS from beginning , all subroutines work correctly.

If I start frmNewClient from beginning, all subroutines work correctly.

If I start frmNewClient from beginning, then if ask frmPOS to show up, frmPOS will show up and all its subroutines work correctly.

If I start frmPOS from beginning, Then if I ask frmNewClient to show up, frmNewClient will show up and all its subroutines work correctly.

If I start frmPOS from beginning, Then if I ask frmNewClient to show up, frmNewClient will show up and all its subroutines work correctly. (but if I need to get back to frmPOS, frmPOS will show up but non of the subroutines will work)

This is my problem and don't know how to solve it
 
Upvote 0
If I start frmPOS from beginning, Then if I ask frmNewClient to show up, frmNewClient will show up and all its subroutines work correctly. (but if I need to get back to frmPOS, frmPOS will show up but non of the subroutines will work)
I'm guessing you're hiding frmPOS instead of unloading it. If not I have no idea what's going on.
 
Upvote 0
No I'm unloading it,

I tried now to put a test formula in cell C1 (C1 = A1 + B1) if I change the value in A1 or B1, C1 didn't update unless I save the workbook!!!
I'm not sure how to solve this and if its related to the main problem

Any suggestions?
 
Upvote 0
If you share a workbook that exhibits these issues I'll take a look and see if I can find anything.
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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