G
Guest
Does anyone know how I can correct this line of VB code that worked in Access97 but is giving a compile error in Access 2000 XP version? I am trying to open the Switchboard items. Please let me know if you need more of my code.
Set rst = dbs.OpenRecordset("Switchboard Items", dbOpenDynaset)
The compile error states that dbOpenDynaset variable not defined.
Here is part of the code:
Private Function HandleButtonClick(intBtn As Integer)
' This function is called when a button is clicked.
' intBtn indicates which button was clicked.
' Constants for the commands that can be executed.
Const conCmdGotoSwitchboard = 1
Const conCmdOpenFormAdd = 2
Const conCmdOpenFormBrowse = 3
Const conCmdOpenReport = 4
Const conCmdCustomizeSwitchboard = 5
Const conCmdExitApplication = 6
Const conCmdRunMacro = 7
Const conCmdRunCode = 8
' An error that is special cased.
Const conErrDoCmdCancelled = 2501
Dim dbs As Object
Set dbs = CurrentDb
Dim rst As Object
Set rst = Recordset
' Dim db As Object
' Set db = dbOpenDynaset
' Dim dbOpenDynaset As Object
' Dim db As AcOpenDataMode
On Error GoTo HandleButtonClick_Err
' Find the item in the Switchboard Items table
' that corresponds to the button that was clicked.
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("Switchboard Items", dbOpenDynaset)
rst.FindFirst "[SwitchboardID]=" & Me![SwitchboardID] & " AND [ItemNumber]=" & intBtn
' If no item matches, report the error and exit the function.
If (rst.NoMatch) Then
MsgBox "There was an error reading the Switchboard Items table."
rst.Close
dbs.Close
Exit Function
End If
I also want to mask the password when users type it in. Here are few codes I have tried. They did not work. Any suggestion will be helpful.
Private Sub Form_Open(Cancel As Integer)
Dim pword As String
Yourname = InputBox("In order to help manage updates, your name will be recorded along with the time. Data entry info can be viewed under the MISC tab. Please provide your name. Data Entry by...")
If Yourname = "" Then DoCmd.Close: Exit Sub
pword = InputBox("Enter the password...")
'Set pword.SetValue = "Password"
'Set pword = "Password" (OBJECT required)
'Set InputMask = "Password" (InputMask is now a variable not defined)
'Set InputBox.InputMask = "####" DID NOT WORK
'Set pword.InputMask = "####" DID NOT WORK
'example for VB InputMask Forms!Customers!Telephone.InputMask = "(###) ###-####"
If Cancel Then DoCmd.Close
'If pword = "zero" Then Set InputBox.InputMask = "####"
'If pword = "zero" Then Set InputBox = "****"'
'If pword = "zero" Then Set InputBox.InputMask SetValue = "****" '
If pword <> "zero" Then DoCmd.Close
End Sub
Set rst = dbs.OpenRecordset("Switchboard Items", dbOpenDynaset)
The compile error states that dbOpenDynaset variable not defined.
Here is part of the code:
Private Function HandleButtonClick(intBtn As Integer)
' This function is called when a button is clicked.
' intBtn indicates which button was clicked.
' Constants for the commands that can be executed.
Const conCmdGotoSwitchboard = 1
Const conCmdOpenFormAdd = 2
Const conCmdOpenFormBrowse = 3
Const conCmdOpenReport = 4
Const conCmdCustomizeSwitchboard = 5
Const conCmdExitApplication = 6
Const conCmdRunMacro = 7
Const conCmdRunCode = 8
' An error that is special cased.
Const conErrDoCmdCancelled = 2501
Dim dbs As Object
Set dbs = CurrentDb
Dim rst As Object
Set rst = Recordset
' Dim db As Object
' Set db = dbOpenDynaset
' Dim dbOpenDynaset As Object
' Dim db As AcOpenDataMode
On Error GoTo HandleButtonClick_Err
' Find the item in the Switchboard Items table
' that corresponds to the button that was clicked.
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("Switchboard Items", dbOpenDynaset)
rst.FindFirst "[SwitchboardID]=" & Me![SwitchboardID] & " AND [ItemNumber]=" & intBtn
' If no item matches, report the error and exit the function.
If (rst.NoMatch) Then
MsgBox "There was an error reading the Switchboard Items table."
rst.Close
dbs.Close
Exit Function
End If
I also want to mask the password when users type it in. Here are few codes I have tried. They did not work. Any suggestion will be helpful.
Private Sub Form_Open(Cancel As Integer)
Dim pword As String
Yourname = InputBox("In order to help manage updates, your name will be recorded along with the time. Data entry info can be viewed under the MISC tab. Please provide your name. Data Entry by...")
If Yourname = "" Then DoCmd.Close: Exit Sub
pword = InputBox("Enter the password...")
'Set pword.SetValue = "Password"
'Set pword = "Password" (OBJECT required)
'Set InputMask = "Password" (InputMask is now a variable not defined)
'Set InputBox.InputMask = "####" DID NOT WORK
'Set pword.InputMask = "####" DID NOT WORK
'example for VB InputMask Forms!Customers!Telephone.InputMask = "(###) ###-####"
If Cancel Then DoCmd.Close
'If pword = "zero" Then Set InputBox.InputMask = "####"
'If pword = "zero" Then Set InputBox = "****"'
'If pword = "zero" Then Set InputBox.InputMask SetValue = "****" '
If pword <> "zero" Then DoCmd.Close
End Sub