Hello Team,
During my project, I met a problem which I will try to clearly explain.
I have one User Form where I want to register new order & update the status. I have created two frames within this User Form with couple fields. On the bottom, there is an list of orders & their status like open, approved or rejected. My idea is to write in the text box number. Based on this text, list from the bottom is searching. If number doesn't exist on the list then left Frame appeared to register new order but when order number exist on the list then right Frame needs to appeared to update status of this order. Hopefuly below pictures will explain better above words.
1) Here I'm wiritng number which isn;t exist on the list & left frame appeared as I expected - this is OK
2) Now, I'm trying to change status of row number 2 with order 1040202 and after Enter, both frames appeared but I need only this from the right side (This is my problem)
Here is my VBA code:
During my project, I met a problem which I will try to clearly explain.
I have one User Form where I want to register new order & update the status. I have created two frames within this User Form with couple fields. On the bottom, there is an list of orders & their status like open, approved or rejected. My idea is to write in the text box number. Based on this text, list from the bottom is searching. If number doesn't exist on the list then left Frame appeared to register new order but when order number exist on the list then right Frame needs to appeared to update status of this order. Hopefuly below pictures will explain better above words.
1) Here I'm wiritng number which isn;t exist on the list & left frame appeared as I expected - this is OK
2) Now, I'm trying to change status of row number 2 with order 1040202 and after Enter, both frames appeared but I need only this from the right side (This is my problem)
Here is my VBA code:
VBA Code:
Sub GetData()
Dim id As String, i As Integer, sh As Worksheet, msgValue As VbMsgBoxResult
If IsNumeric(mapFORM.txtRollNo.Value) Then
i = 1
Set sh = ThisWorkbook.Sheets("Database")
id = mapFORM.txtRollNo.Value
Do While sh.Cells(i + 1, 3).Value <> ""
If sh.Cells(i + 1, 3).Value = id Then
Select Case sh.Cells(i + 1, 8).Value
Case "Otwarte"
mapFORM.Frame3.Visible = True
mapFORM.Frame4.Visible = False
mapFORM.UpdateButton.Visible = True
mapFORM.SubmitButton.Visible = False
Case Else
msgValue = MsgBox("Zlecenie zostało już przebadane. Czy chcesz zmienić status tego zlecenia ?", vbYesNo + vbInformation, "Confirmation")
If msgValue = vbYes Then
mapFORM.Frame3.Visible = True
mapFORM.Frame4.Visible = False
mapFORM.UpdateButton.Visible = True
mapFORM.SubmitButton.Visible = False
End If
End Select
ElseIf sh.Cells(i + 1, 3).Value <> id Then
mapFORM.Frame3.Visible = False
mapFORM.Frame4.Visible = True
mapFORM.SubmitButton.Visible = True
mapFORM.UpdateButton.Visible = False
End If
i = i + 1
Loop
End If
End Sub