Solved

Passing parameters to a Data Environment Command Object at runtime

Posted on 2002-03-18
5
1,163 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 51

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

733 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