Can't change recordsource property in new form 
Author Message
 Can't change recordsource property in new form

I'm using VB5 learning edition, I have two forms, linked to the same
database(an address book style affair) The first form performs a search
function through building an SQL query and putting the a limited number of
fields (ie Name, Phone) in a DBGrid. Next I want the user to be able to
DblClick on the required record in the grid to load a new form with all of
the other fields( name, phone, address, favourite pizza etc.)

at the moment my code looks like this in the first form;

Private Sub DBGrid1_DblClick()

Dim HSID As Long
'Primary key
Dim HSqry As String
'Query to insert in recordsource

HSID = DataHS.Recordset.Fields("HSID").Value        'extract unique index
from record clicked

 HSqry = "Select * from Homestay where HSID = " & HSID      'Build Query

 Load frmProvider                                                   'Load
second form(with all fields showing)

'insert query
 frmProviderDatabase.DataHomestayDatabase.RecordSource = HSqry

frmProvider.Show (0)
'show form

 frmProvider.DataHomestayDatabase.RecordSource = HSqry    'I tried to insert
it here too

 End Sub

I have altered the recordsource property at design with no effect.  Do I
need to pass the query to the second form.  Probably very simple I know..

Thanks for any help

Russ



Fri, 02 Nov 2001 03:00:00 GMT  
 Can't change recordsource property in new form
I have just glanced at this so not sure, but it seems you have decleared
HSQRY locally but are trying to reference it within another form. Try making
it a global variable.

Regards,
Richard.

Quote:

>I'm using VB5 learning edition, I have two forms, linked to the same
>database(an address book style affair) The first form performs a search
>function through building an SQL query and putting the a limited number of
>fields (ie Name, Phone) in a DBGrid. Next I want the user to be able to
>DblClick on the required record in the grid to load a new form with all of
>the other fields( name, phone, address, favourite pizza etc.)

>at the moment my code looks like this in the first form;

>Private Sub DBGrid1_DblClick()

>Dim HSID As Long
>'Primary key
>Dim HSqry As String
>'Query to insert in recordsource

>HSID = DataHS.Recordset.Fields("HSID").Value        'extract unique index
>from record clicked

> HSqry = "Select * from Homestay where HSID = " & HSID      'Build Query

> Load frmProvider                                                   'Load
>second form(with all fields showing)

>'insert query
> frmProviderDatabase.DataHomestayDatabase.RecordSource = HSqry

>frmProvider.Show (0)
>'show form

> frmProvider.DataHomestayDatabase.RecordSource = HSqry    'I tried to
insert
>it here too

> End Sub

>I have altered the recordsource property at design with no effect.  Do I
>need to pass the query to the second form.  Probably very simple I know..

>Thanks for any help

>Russ



Fri, 02 Nov 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Changing Form's BorderStyle property at run time but before form is loaded

2. dynamically changing the Recordsource Property?

3. changing the recordsource property at runtime

4. Dynamic changes to RecordSource Property?

5. Setting a recordset object to a data control's recordsource property

6. 'Canned' data in VB program

7. Changing a control's properties from another form in a project

8. Changing Project's Form Properties

9. Changing ADODC.RecordSource programatically doesn't return expected records

10. RecordSource change not reflected in data form

11. Parameter Query as a Form's RecordSource

12. Progress Bar - whilst Access form's Recordsource is requerying

 

 
Powered by phpBB® Forum Software