Results 1 to 4 of 4
  1. #1
    venu_resoju is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2011
    Posts
    19

    A text box value on a form controlled by two buttons on other form

    Hai Friends..


    I have a form "Payroll" which contain two buttons named "PayrollbyDailyAttendance" and "PayrollbyMonthlyAttendance".I have given a code for these two buttons is as below.
    Code:
    Private Sub PayrollbyMonthlyAttendance_Click()
    DoCmd.OpenForm "PayrollCreation", , , , , , "Monthly"
    End Sub
    Code:
    Private Sub PayrollbyDailyAttendance_Click()
    DoCmd.OpenForm "PayrollCreation", , , , , , "Daily"
    EndSub

    I have another form "PayrollCreation" which contain a text boxe named "txtNoofDaysWorked".
    I have given the code on "PayrollCreation" onLoad event is as below

    Code:
    Private Sub Form_Load()
    Select Case Nz(Me.OpenArgs, vbNullString)
       
     Case "Daily"
            Me.txtNoofDaysWorked.Value = DCount("[EmpID]", "Attendance", "[EmpID]='" & [cboEmpName] & "' AND [AttendanceMonth]='" & [cboMonth] & "' AND [AttendanceYear]='" & [cboYear] & "' AND [AttendanceStatus]='" & "Present" & "'")
            Me.txtNoofDaysWorked.Requery
        
    Case "Monthly"
            Me.txtNoofDaysWorked.Value = 0
        
    End Select
    End Sub
    but when I click "PayrollbyDailyAttendance" Button,

    Me.txtNoofDaysWorked.Value = DCount("[EmpID]", "Attendance", "[EmpID]='" & [cboEmpName] & "' AND [AttendanceMonth]='" & [cboMonth] & "' AND [AttendanceYear]='" & [cboYear] & "' AND [AttendanceStatus]='" & "Present" & "'")
    is working (I observed when clicking/changed design view to form view) but not Re-querying.


    when I click "PayrollbyMonthlyAttendance" Button, "txtDaysWorked= "0" is working fine.

    Please see my attached DB and get my exact problem...



    Thanks in advance..
    Attached Files Attached Files

  2. #2
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    Couple of thoughts

    Have you tried inserting "formname.requery" after you have created the filters you described?
    You might look at the Mytestform.zip in this thread:
    https://www.accessforums.net/forms/f...xes-18492.html

  3. #3
    venu_resoju is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Feb 2011
    Posts
    19
    I have tried like
    Code:
    "Forms!PayrollCreation!txtNoofDaysWorked.Requery"
    and
    Code:
    "Forms!PayrollCreation.Requery"
    but it is not working.

  4. #4
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481
    I won't have my Access PC to look at your DB until late today. As a guess, copy or move the code shown to the Form OnCurrent event.
    I read your first post as needing the txtnoofdaysworked for a subsequent query. If the textnoofdaysworked is the desired result, then the requery is superfluous.
    Last edited by hertfordkc; 10-29-2011 at 04:46 AM. Reason: incomplete

Please reply to this thread with any new information or opinions.

Similar Threads

  1. GO TO buttons on form
    By csh in forum Forms
    Replies: 8
    Last Post: 10-23-2011, 06:40 AM
  2. Buttons on form to navigate through records
    By emilyrogers in forum Forms
    Replies: 2
    Last Post: 07-19-2011, 10:17 AM
  3. Buttons activating on form startup
    By howieyo in forum Forms
    Replies: 0
    Last Post: 06-13-2011, 06:48 PM
  4. Form and Buttons
    By rmohebian in forum Forms
    Replies: 1
    Last Post: 02-14-2011, 09:57 AM
  5. Edit Buttons for a Rich Text Box on Form
    By trb5016 in forum Forms
    Replies: 2
    Last Post: 10-13-2010, 12:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums