Solved Instead of Ms access in msgbox heading I should be able to write something else. (1 Viewer)

Local time
Today, 18:17
Joined
May 11, 2023
Messages
46
Hello everyone,
Kindly assist me with the following code when executed should not show Microsoft access. It should show something else which I will write.

Code:
Private sub Form_Open(Cancel As Integer)

    If StrComp(InputBox("Please enter the Password."), "123", 0) <> 0 Then
Cancel= True
MsgBox "Wrong Password.", v information or vbOkOnly, "Operation Cancelled"
End If
End Sub

Thanks in advance
 
Hello everyone,
Kindly assist me with the following code when executed should not show Microsoft access. It should show something else which I will write.

Code:
Private sub Form_Open(Cancel As Integer)

    If StrComp(InputBox("Please enter the Password."), "123", 0) <> 0 Then
Cancel= True
MsgBox "Wrong Password.", v information or vbOkOnly, "Operation Cancelled"
End If
End Sub

Thanks in advance
Try:
MsgBox ("Wrong Password.", vbInformation + vbOkOnly, "Operation Cancelled")
 
Written a little better:
Code:
Private Sub Form_Open(Cancel As Integer)
   Dim EnteredPass As String
   Pass_1 = InputBox("Please enter the Password.", "Secure Entry")
   If StrComp(EnteredPass, "123", 0) <> 0 Then
      Cancel = True
      MsgBox "Wrong Password.", vbInformation + vbOKOnly, "Operation Cancelled"
   End If
End Sub
 
Your call to InputBox() only provides a single parameter, which is the prompt. To set the title of that dialog, provide a second parameter, which is the title...
Code:
Private sub Form_Open(Cancel As Integer)
   dim rsp as string

   rsp = InputBox("Please Enter Password...", "InputBox Title Goes Here")
   Select Case rsp
   Case "123"
      ' correct password, proceed with form open
   Case ""
      ' user cancelled, so cancel without without msgbox
      Cancel = True
   Case Else
      ' user provided incorrect password
      Cancel= True
      MsgBox "Incorrect Password.", vbInformation or vbOkOnly, "Operation Cancelled"
   End If
End Sub
 
Your call to InputBox() only provides a single parameter, which is the prompt. To set the title of that dialog, provide a second parameter, which is the title...
Code:
Private sub Form_Open(Cancel As Integer)
   dim rsp as string

   rsp = InputBox("Please Enter Password...", "InputBox Title Goes Here")
   Select Case rsp
   Case "123"
      ' correct password, proceed with form open
   Case ""
      ' user cancelled, so cancel without without msgbox
      Cancel = True
   Case Else
      ' user provided incorrect password
      Cancel= True
      MsgBox "Incorrect Password.", vbInformation or vbOkOnly, "Operation Cancelled"
   End If
End Sub
It works perfectly. Instead of End If, it should be End Select.
Thanks so much.
 

Users who are viewing this thread

Back
Top Bottom