Results 1 to 10 of 10

Thread: doubt report

  1. #1
    2 Star Lounger
    Join Date
    Jan 2012
    Posts
    155
    Thanks
    118
    Thanked 0 Times in 0 Posts

    doubt report

    friends,

    I have a form with some text boxes and a button that opens a report in accordance with the values ​​of these boxes. how do
    to report after the close, open this same form, but with the values ​​that were previously.

    Thanks for helping.

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,435
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Fabio,

    My suggestion would be to write some code on the Form BeforeClose event to save the current settings to an Access table then include code in the FormOpen event to read the table and set the form fields to the values saved there.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. The Following User Says Thank You to RetiredGeek For This Useful Post:

    fabiobarreto10 (2012-10-06)

  4. #3
    2 Star Lounger
    Join Date
    Jan 2012
    Posts
    155
    Thanks
    118
    Thanked 0 Times in 0 Posts
    Thanks Geek, great suggestion. I will do that and return ..

  5. #4
    2 Star Lounger
    Join Date
    Jan 2012
    Posts
    155
    Thanks
    118
    Thanked 0 Times in 0 Posts
    RetiredGeek,

    could partially solve ... when I put a value on all criteria, the report opens normally and closes when you open the form with all previously selected values​​, perfect.

    But when I leave some or more textboxes or combobox worthless,(one or more criteria worthless) my code does not insert values ​​in the table(all fields is worthless). I am not able to identify the reason.

    these are the codes:

    Private Sub cmdFilter_Click()

    'this is only the part code the table help

    Dim get_User As Variant
    Dim get_Date_Start As Variant
    Dim get_Date_End As Variant
    Dim get_Name_Form As Variant
    Dim get_Company As Variant
    Dim get_Product As Variant

    Const conJetDate = "\#mm\/dd\/yyyy\#"

    get_User = Me.Comb_assessor_auditoria.Column(1)
    get_Date_Start = Me.txtStartDate
    get_Date_End = Me.txtEndDate
    get_Nome_Form = Me.Comb_nome_form.Column(1)

    If IsNull(get_Name_Form) Then
    get_Name_Form = ""
    End If

    get_Company = Me.Comb_empresa_auditoria.Column(1)
    get_Product = Me.Combinação9.Column(1)

    Dim Db As Database, sql As String, sql2 As String

    Set Db = CurrentDb

    CurrentDb.Execute "DELETE * FROM tblLogHelp"

    sql2 = "INSERT INTO tblLogHelp(User, LogDateStart, LogDateEnd, NameForm, NameCompany, NameProduct) VALUES ('" & get_User & "', " & "(" & Format(get_Date_Start, conJetDate) & "), " & "(" & Format(get_Date_End, conJetDate) & "), '" & get_Name_Form & "' , '" & get_Company & "', '" & get_Product & "')"

    Me.Refresh
    CurrentDb.Execute sql2


    End Sub

    Private Sub Form_Open(Cancel As Integer)

    '---------start help table

    Dim get_User As Variant
    Dim get_Date_Start As Variant
    Dim get_Date_End As Variant
    Dim get_Name_Form As Variant
    Dim get_Company As Variant
    Dim get_Product As Variant

    Dim Db As Database, rs As Recordset

    Set Db = CurrentDb

    Set rs = Db.OpenRecordset("SELECT User, LogDateStart, LogDateEnd, NameForm, NomeCompany, NomeProduct FROM tblLogHelp")
    If rs.BOF Then
    GoSub teste
    End If

    get_User = rs.Fields(0)
    get_Date_Start = rs.Fields(1)
    get_Date_End = rs.Fields(2)
    get_Name_Form = rs.Fields(3)
    get_Company = rs.Fields(4)
    get_Product = rs.Fields(5)


    Me.Comb_assessor_auditoria = get_User
    Me.txtStartDate = get_Date_Start
    Me.txtEndDate = get_Date_End
    Me.Comb_nome_form = get_Name_Form
    Me.Comb_empresa_auditoria = get_Company
    Me.Combinação9 = get_Product

    teste:

    Me.Frame10.Visible = False
    Me.Comando10.SetFocus

    End Sub


    Where am I going wrong?

    Thanks for helping.
    Last edited by fabiobarreto10; 2012-10-06 at 16:55.

  6. #5
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,435
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Fabio,

    I'm not up on SQL but by guess would be that the INSERT INTO statement has problems with the blanks generated by empty {"worthless"} fields.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  7. The Following User Says Thank You to RetiredGeek For This Useful Post:

    fabiobarreto10 (2012-10-06)

  8. #6
    2 Star Lounger
    Join Date
    Jan 2012
    Posts
    155
    Thanks
    118
    Thanked 0 Times in 0 Posts
    I did the following test:

    only one field without value criteria in the form.

    In INSERT INTO I pulled this field without value. But not entered any value in the table.

    Do not have the possibility to insert values ​​in the table for only a few fields?

  9. #7
    2 Star Lounger
    Join Date
    Jan 2012
    Posts
    155
    Thanks
    118
    Thanked 0 Times in 0 Posts
    I managed to solve the problem with two lines of code:

    Forms!NomeForm.visible=false
    Forms!NomeForm.visible=true

    * I had trying this possibility, but always got an error message saying that the form was not found. I forgot that I had put in evendo by clicking the button that opens the report to close the form, but now removed this line and it worked perfectly as I was trying.

    thank you so very much! :-)

  10. #8
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,435
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    Fabio,

    Glad you got it sorted out!
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  11. The Following User Says Thank You to RetiredGeek For This Useful Post:

    fabiobarreto10 (2012-10-06)

  12. #9
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts
    Seeing the button has 2 values do you write it away as yes or no?

    If so i would make that table bound to the form and set no additions to true, i'd also take out the navigation buttons. In this way there is not code required in the form for OnOpen or OnClose events.

  13. The Following User Says Thank You to patt For This Useful Post:

    fabiobarreto10 (2012-10-06)

  14. #10
    2 Star Lounger
    Join Date
    Jan 2012
    Posts
    155
    Thanks
    118
    Thanked 0 Times in 0 Posts
    Hi Patt, thanks for help.

Posting Permissions

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