Solved

Passing parameters to a Data Environment Command Object at runtime

Posted on 2002-03-18
5
1,157 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thank for all the help. I'm on the road again!

Robert
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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

763 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

13 Experts available now in Live!

Get 1:1 Help Now