Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refering To or Passing A DataGrid Value to New Form

Status
Not open for further replies.

tfayer

Technical User
Aug 4, 2002
41
US
I have DataGrid1 based on a ADO Recordset that displays Each Account and Some Info about that Account. So each row is a different account. In column 1 is the account Id (CON_ID). In the double click event of DataGrid1 I have placed Form2.Show and want this to display information for The account selected.

I have tried using frmAccounts.DataGrid1("CON_ID") in Form2 but I get Wrong Number of Arguments or Data Member Not Found.

How Do I refer to this field or do I need to pass it to the new form as an argument?


A Second Question:

I would like my forms to do different things in difgferent situations. Basically I want to pass a value to a form and depending on that value have th form operate differently(such as an editing mode or just a display mode OR To show certain buttons when opened from FormA but dont show them when opened from formB)

I tried placing code in Load Event of the form but When I place an argument I get an error saying Procedure declaration does not match description of event or method having the same name.

How can I accomplish this.

Thanks
 
Private Sub Adodc1_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)

'Put here to load form2 or blah blah
'form2.text1.DataField = 'Table
End Sub
 
1.
Either:
frmAccounts.DataGrid1(x)
where x = column number,
or, referer to the underlying recordset:

frmAccounts.ADODC1.Recorset.Fields("CON_ID")
frmAccounts.myRS.Fields("CON_ID")

2.
You cannot change the arguments for the Load event.
You can either create a public variable and set it's value prior to loading the form:
===================================
In Form2 Declarations:
Option explicit
Public FormMode As Long

Private Sub Form_Load()
If FormMode =1 then
'Code
End If
End Sub

In some Sub proceedure in Form1:
Dim frm As New Form1
frm.FormMode = 2
'Load frm 'not needed
frm.Show
===================================
Or, create your own load proceedure:
Form2

Public Sub Display (FormMode As Long)
if FormMode = 2 then
'Code
End If
Me.Show
End Sub

And in Form1:

Dim frm As New Form1
frm.Display

[/b][/i][/u][sub]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top