?
Solved

Passing parameters to a Data Environment Command Object at runtime

Posted on 2002-03-18
5
Medium Priority
?
1,171 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 53

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 150 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Suggested Courses
Course of the Month15 days, 6 hours left to enroll

770 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