Sheinen
New member
- Local time
- Today, 07:21
- Joined
- Mar 16, 2021
- Messages
- 3
So I am trying to make a button in my database open the report "Paid Subscriptions for the Month" but it first has to check a table that contains each what permissions each clearance level has. It is supposed to check the table, see if it has access and then open the report of he/she has access. It keeps on telling me that there is a data type mismatch in the criteria expression of rs.FindFirst. TempVars("Clvl") is a number but all items are that in the field "ClearanceLevel".
This is my code:
I've tested the following code to see if it works without checking but it only executes the else and not the then:
Can anyone help me figure out what's wrong and if this code will actually work? If it won't work, any suggestions?
I've attached the back end so you can see the tables used. The data inside is messy and a bit inefficient but please do not mind that for it still needs to be worked on after.
This is my code:
Code:
Private Sub btnPaidSub_Click()
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("Clearance Permissions", dbOpenSnapshot, dbReadOnly)
rs.FindFirst "ClearanceLevel = '" & TempVars("Clvl") & "'"
If rs!ObjectName = "Paid Subscriptions for the Month" And rs!HasAccess = True Then
DoCmd.OpenReport "Paid Subscriptions for the Month", acViewReport
Else
MsgBox "You do not have clearance!!!"
End If
End Sub
I've tested the following code to see if it works without checking but it only executes the else and not the then:
Code:
Private Sub btnPaidSub_Click()
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("Clearance Permissions", dbOpenSnapshot, dbReadOnly)
If rs!ObjectName = "Paid Subscriptions for the Month" And rs!HasAccess = True Then
DoCmd.OpenReport "Paid Subscriptions for the Month", acViewReport
Else
MsgBox "You do not have clearance!!!"
End If
End Sub
I've attached the back end so you can see the tables used. The data inside is messy and a bit inefficient but please do not mind that for it still needs to be worked on after.