Results 1 to 4 of 4

Thread: Data Report, filter data enviroment with user input

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Location
    Sunny Bournemouth UK
    Posts
    145

    Exclamation Data Report, filter data enviroment with user input

    Hi,
    Im using VB6 and have a data report with a data enviroment. The data enviroment runs off a query in my access db which combines the adviser with there rotas. The results of the query are a long list of everyone in the db and there rota which is fine. In my interfcae ive got a form called frmselectrota which has a text box, i need the user to be able to enter there ext number (unique) and then when a button is clicked the datareport will be filtered to show only that person rotas. Ive been looking around and i cant seem to find a simple piece of code to filter the data enviroment... as the data enviroment runs frtom a access query there is no vb side sql...
    any ideas greatly appriciated!!

  2. #2
    Hyperactive Member
    Join Date
    May 2005
    Posts
    324

    Re: Data Report, filter data enviroment with user input

    You could create a command object that uses an SQL string, and rewrite the string in code when you call the command object, using the commandtext property


    VB Code:
    1. if dataenvironment1.rsMyCommand.State = adStateOpen then dataenvironment1.rsMyCommand.close
    2. dataenvironment1.commands("MyCommand").commandtext = "select something  from MyRotaQuery where somefield  = '" & frmselectrota.Text1 & "'

    Of course omit the single quotation marks if it is not a string variable.

  3. #3
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Data Report, filter data enviroment with user input

    Something like this should also work...

    VB Code:
    1. DataEnvRpt.rsCommandRpt.Open "your sql"
    2. Report.Refresh
    3. Report.Show
    4. DataEnvRpt.rsCommandRpt.Close
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Location
    Sunny Bournemouth UK
    Posts
    145

    Re: Data Report, filter data enviroment with user input

    dee-u, hello mate, the code you suggest.. is where would that be placed... on the command button on the selection form?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width