Tim Thiessen
tim at irwin-greenhouses.com
Tue Sep 16 08:10:18 CDT 2003
Hi List! I am having a problem understanding how to reference the recordsource in a report. I need to have a text box in a report show 1 of 3 possible fields in a report. I am using the following code to do this. When I run the report, I get the error message "Type mismatch" with the code "Me.Recordsource" highlighted. Can anyone suggest what I am doing wrong or a better way to do this? Private Sub Report_Open(Cancel As Integer) Dim CurDb As Database Dim rstInv As Recordset, rstPricing As Recordset Dim strInv As String Set CurDb = CurrentDb strInv = "SELECT Customers.[Customer Number], Customers.[Pricing Type], Customers.Code " _ & "FROM Customers " _ & "WHERE Customers.[Customer Number]= '" & Forms!frmAckCustInventory![cboCustomer] & "';" Set rstPricing = CurDb.OpenRecordset(strInv, dbOpenDynaset) Me!PricingCode = rstPricing!Code Set rstInv = Me.RecordSource Select Case rstPricing!Code Case 1 Me!Price = rstInv!QtyPrice Case 2 Me!Price = rstInv!PrebookPrice Case 3 Me!Price = rstInv!WhlsePrice End Select End Sub Tim Thiessen