RomeoJuliet
Registered User.
- Local time
- Today, 14:38
- Joined
- Nov 20, 2008
- Messages
- 23
Please be gentle, I'm new to Access...
I have an Order Processing app based on Northwind. I've modified table [order details] to include a yes/no field 'canVisit'. The Orders/Orders Subform look quite similar to the original, but I have buttons on the Orders form which I only want to be visible if there is at least one row in [order details] for the current order where canVisit = true.
I have code behind the afterUpdate event on the subform as follows:
This is failing with the error "Runtime error 3061. Too few parameters. Expected 1.".
Any help would be greatly appreciated. I readily admit I really don't know what I'm doing!
Thanks, Mike.
I have an Order Processing app based on Northwind. I've modified table [order details] to include a yes/no field 'canVisit'. The Orders/Orders Subform look quite similar to the original, but I have buttons on the Orders form which I only want to be visible if there is at least one row in [order details] for the current order where canVisit = true.
I have code behind the afterUpdate event on the subform as follows:
Code:
Private Sub Form_AfterUpdate()
Dim db As Database
Dim Lrs As DAO.Recordset
Dim LSQL As String
Dim Lcnt As Integer
'Open connection to current Access database
Set db = CurrentDb()
'Create SQL statement to retrieve filtered row count from [order details] table
LSQL = "SELECT count(*) FROM Products INNER JOIN [Order Details] " & _
"ON Products.ProductID = [Order Details].ProductID " & _
"WHERE [Order Details].OrderID=Me!OrderID AND Products.CanVisit=True;"
Set Lrs = db.OpenRecordset(LSQL)
'Retrieve value if data is found
If Lrs.EOF = False Then
Lcnt = Lrs("order details")
Else
Lcnt = 0
End If
Lrs.Close
Set Lrs = Nothing
If Lcnt > 0 Then
Set [Forms]![orders]![btnAdultVisit].Visible = True
Set [Forms]![orders]![btnYouthVisit].Visible = True
Else
Set [Forms]![orders]![btnAdultVisit].Visible = False
Set [Forms]![orders]![btnYouthVisit].Visible = False
End If
End Sub
This is failing with the error "Runtime error 3061. Too few parameters. Expected 1.".
Any help would be greatly appreciated. I readily admit I really don't know what I'm doing!
Thanks, Mike.