[AccessD] Referencing Recordsource in Report

Gustav Brock gustav at cactus.dk
Tue Sep 16 09:23:29 CDT 2003


Hi Tim

.RecordSource is nothing but a string - with either the name of a
table or query or an SQL string.

Try to insert:

  MsgBox Me.RecordSource

Maybe

  Set rst = Me.RecordsetClone

is what you are looking for?

/gustav


> 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



More information about the AccessD mailing list