Solved

Passing parameters to a Data Environment Command Object at runtime

Posted on 2002-03-18
5
1,167 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 52

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 70

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 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