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

Local time
Today, 06:13
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
 

bob fitz

AWF VIP
Local time
Today, 04:13
Joined
May 23, 2011
Messages
4,728
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")
 

Mike Krailo

Well-known member
Local time
Yesterday, 23:13
Joined
Mar 28, 2020
Messages
1,046
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
 

MarkK

bit cruncher
Local time
Yesterday, 20:13
Joined
Mar 17, 2004
Messages
8,190
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
 
Local time
Today, 06:13
Joined
May 11, 2023
Messages
46
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

Top Bottom