[AccessD] Referencing Recordsource in Report

Tim Thiessen tim at irwin-greenhouses.com
Tue Sep 16 10:26:16 CDT 2003


Gustav,

Thanks your help.  Evidently, RecordsetClone is not a property of reports,
only forms.  Any other suggestions?
Tim

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Gustav Brock
Sent: Tuesday, September 16, 2003 9:23 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Referencing Recordsource in Report


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

_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list