Solved

Passing parameters to a Data Environment Command Object at runtime

Posted on 2002-03-18
5
1,158 Views
Last Modified: 2007-11-27
I have a form with a control array of comboboxes and a MSHFlexgrid. The comboboxes are populated from a database table at runtime. I want to display the results of a Data Environment Command, which returns a recordset, in the flexgrid based upon the name the user selects from the combobox. How do I pass the user selection as a parameter to the command object? I can easily get the entire table into the grid with the command text "SELECT * FROM DailyShiftReports" but if I narrow the criteria to "SELECT * FROM DailyShiftReports WHERE EmployeeName = "' & cboEmployeeMaster(0). & "' I get nothing. How can I reload the grid using code in the combobox's click event? Or is my approach faulty?

Robert
0
Comment
Question by:bob_aloo
5 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6878759
Hi,

cboEmployeeMaster(0). or cboEmployeeMaster(0) ?

Do you declare cboEmployeeMaster(0) as Public?

or you should put it like this myForm.cboEmployeeMaster(0) if it's a combo box.
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 6878901
replace the datareport with the grid in the following example and it will work: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q244779
0
 

Author Comment

by:bob_aloo
ID: 6878965
Emoreau

I think you have me on the right track but I'm not there yet. My command text is now "Select * FRom DailyShiftReports where EmployeeName = ?".
I'm a little confused about the parameters tab though. I gave it the name: pName, direction: input, host data type: string, required: true, value: frmGroupByEmpl.cboEmployeeName.Text. Is all that correct? Where do I again refer to pName?

At this point I'm still getting a blank grid. My code in the click event is:

Private Sub cboEmployeeName_Click()
  Load deGinger
  With deGinger
    If .rscmdGroupByEmployee.State <> 0 Then
      .rscmdGroupByEmployee.Close
      .cmdGroupByEmployee cboEmployeeName.Text
    End If
  End With
  MSHFlexGrid.Refresh
  If MSHFlexGrid.Visible = False Then
    MSHFlexGrid.Visible = True
  End If
 
  'sync boxes
  cboHireDate.ListIndex = cboEmployeeName.ListIndex
End Sub

Robert
0
 

Accepted Solution

by:
talluri_28 earned 50 total points
ID: 6878999
Hi

in dataenvironment command text u have to give sql String as

"SELECT * FROM
DailyShiftReports WHERE EmployeeName = ?"

Select the Employee Name in Combobox  
then u pass the parameter to de.command1 combo1.text

Example :

Private Sub Combo1_Click()
  DataEnvironment1.Command1 Combo1.Text
  Set MSHFlexGrid1.DataSource =DataEnvironment1.rsCommand1
End Sub

It will display the Record Details into u r grid

Jagadeesh
0
 

Author Comment

by:bob_aloo
ID: 6879072
Thank for all the help. I'm on the road again!

Robert
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Use Multiple Forms 4 49
DIR issue 7 51
Excel Vlookup to move data back to source. 4 84
using web browser with BING 40 110
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now