USER Form after change MSGBOX

mahhdy

Board Regular
Joined
Sep 15, 2016
Messages
86
Hi,
I have a user form, the user can enter data for several rows by clicking to "add item" button. I want if the user actually adds any rows (data) to the file, he/she receives a code to use it for the uploading purpose. I have a code which reads the ID row and last integer digit of the time, but I don't know how to ask VBA to send the code to the user if he/she really changed the data set.

Thanks
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
My idea is to allocate that code to a global variant in form initialize action and checking the code of form termination stage with that. So if they do not match, The procedure shows the code, otherwise nothing.
I did below, but not working, Any Idea?
Code:
Private Sub UserForm_Initialize()
Application.ScreenUpdating = False
'    Sheet2.Activate
    txtrn.SetFocus
    DTPicker.Value = Date
' Clear the values
    txtrn.Value = ""
    cmbuser.Clear
    Call emptyfileds
    Txtqty.Value = 1
' Combo fields add item
'    Call addcmbo
    firstcode = Cells(WorksheetFunction.CountA(Range("w:w")), 23)
    eroom1 (firstcode)
End Sub

Private Sub UserForm_Terminate()
    Call eroom1(firstcode)
    MsgBox code
    Dim eroom As String
    eroom = Cells(WorksheetFunction.CountA(Range("w:w")), 23)
    MsgBox "First Eroom Code = " & code & Chr(10) & "Last Eroom Code = " & eroom
    If eroom <> code Then MsgBox "Please use this code for EROOM update value:" & Chr(10) & "     " & eroom, , "Reminder"
End Sub

Public Sub eroom1(code As Variant)
    
End Sub

Hi,
I have a user form, the user can enter data for several rows by clicking to "add item" button. I want if the user actually adds any rows (data) to the file, he/she receives a code to use it for the uploading purpose. I have a code which reads the ID row and last integer digit of the time, but I don't know how to ask VBA to send the code to the user if he/she really changed the data set.

Thanks
 
Upvote 0
I solved it,
I defined two public variable at the beginning of my codes, and set their data accordingly (firstcode on initialization of the form and lastcodeon termination) and one simple if.
here below you will find it.
Code:
 Public firstcode As String
Public lastcode As String

Private Sub UserForm_Initialize()
Application.ScreenUpdating = False
'    Sheet2.Activate
    txtrn.SetFocus
    DTPicker.Value = Date
' Clear the values
    txtrn.Value = ""
    cmbuser.Clear
    Call emptyfileds
    Txtqty.Value = 1
' Combo fields add item
'    Call addcmbo
    firstcode = Cells(WorksheetFunction.CountA(Range("w:w")), 23)

End Sub

Private Sub UserForm_Terminate()

    lastcode = Cells(WorksheetFunction.CountA(Range("w:w")), 23)
    If fisrtcode <> lastcode Then MsgBox "Please use this code for EROOM update value:" & Chr(10) & "     " & lastcode, , "Reminder"
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,202,993
Messages
6,052,968
Members
444,622
Latest member
Kriszilla

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