Results 1 to 12 of 12
  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Setfocus (A2000)

    With the attached pic.

    Can any one help with a setfocus problem.
    The menu in the pic(Blue) is a pop-up called from the VbKeyF7, I want to reference [EstimateNo] in the subform of the first tab by pressing the first button "Labour By Job" and so-forth next with the other buttons.

    Main form = frmLabourOperations
    Tab Page = Labour_By_Job
    subform = sbfLabourByJob
    Field req = [EstimateNo]

    I've tried all alternatives with no success.

    Dave
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Setfocus (A2000)

    If you want to refer to a control on a subform, use something like the following:

    frmLabourOperations!sbfLabourByJob!EstimateNo

    The subject of your post says SetFocus, so maybe you want to set focus to a control on a subform. You must do this in 2 steps: first set focus to the subform, then to a control in the subform. The tab control doesn't come into play. Access will switch to the appropriate tab page automatically.

    frmLabourOperations!sbfLabourByJob.SetFocus
    frmLabourOperations!sbfLabourByJob!EstimateNo.SetF ocus

  3. #3
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Setfocus (A2000)

    Hans

    I must be having a bad run lately.

    Your syntax works.

    I tried all kinds of altenatives:-

    Forms!frmLabourOperations.Form!sbfLabourByJob!Esti mateNo.setFocus

    or

    Forms!frmLabourOperations.Controls.Labour_By_Job etc etc etc

    It just goes to show, try the obvious first.

    Regards

    Dave

  4. #4
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Setfocus (A2000)

    Just an after thought.

    The focus has set in the field, but cannot edit unless I actually click in the focussed field.
    The whole field is highlited and no flashing cursor for edit mode. ?


    Is there a way to set the focus and be able to edit.

    Dave

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Setfocus (A2000)

    <P ID="edit" class=small>Edited by HansV on 19-Jul-02 09:22.</P>This is standard behaviour when setting focus to a text box.

    You have several options:
    1. <LI>Add a line

      frmLabourOperations!sbfLabourByJob!SelStart = Len(frmLabourOperations!sbfLabourByJob!EstimateNo. Text)

      to set the blinking cursor to the end of the text, - OR -
      <LI>Press F2 to edit the contents of the text box, - OR -
      <LI>Select Tools/Options..., select the Keyboard tab, and set the Focus after Move (?) option to the setting you like.
    HTH,
    Hans

    Added by HansV: Oops - originally wrote SelEnd where it should have been SelStart in the first option.

  6. #6
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Setfocus (A2000)

    I'm getting error 424 object required. ??

    Forms!frmLabourOperations!sbfLabourByJob!SelEnd = Len(frmLabourOperations!sbfLabourByJob!EstimateNo. Text)

    Dave


    Private Sub Command1_Click()
    Forms!frmLabourOperations!sbfLabourByOperative.Set Focus
    Forms!frmLabourOperations!sbfLabourByOperative!Nam e.SetFocus
    Forms!frmLabourOperations!sbfLabourByJob!SelEnd = Len(frmLabourOperations!sbfLabourByJob!EstimateNo. Text)
    'DoCmd.GoToRecord , , acNewRec
    DoCmd.Close acForm, "mnuLabourSelection"
    End Sub


    Sorry, Just noticed your edit

  7. #7
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Setfocus (A2000)

    Still getting error 424 object required.

    Dave

    Sorted.
    I was confused as to why, when the field on the sub HAD recieved the focus and I couldn't do anything with it.
    The menu form wasn't giving IT'S focus away back to frmLabourOperations.
    So in the close event of the menu pop-up, I put

    Forms!frmLabourOperations.SetFocus

    Again, some-times it's the most obvious errors that cause the problems.

    Its been a bad week, now I'm going down the pub.
    Night all, and have a good weekend.

    Dave

  8. #8
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Setfocus (A2000)

    Going right back to my first post, Having sorted the setfocus problem.

    I now need to start Summing the totals.

    I'm not sure whether to use DlookUp or Dsum.
    I can add the totals quite easily in the footer by =Sum([TG]) etc but this will add the total all together.
    I can use =DSum("[TG]","LABOUR BOOKING","[OPERATION]='PAINT'") but this adds ALL from the table direct.

    I want a text in the footer that will add only for the current record displayed.
    Perhaps a mixture of the two expressions.

    =Sum([TG]) of "Paint"
    =Sum([TG]) of"Body" etc etc etc

    Can someone help me to achieve this.

    Dave
    Attached Files Attached Files

  9. #9
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Setfocus (A2000)

    Sorry, but *where* are you trying to put this? You appear to have attempted it on both the subform and form, based on the graphic you attached. And what do you mean by current record? A Sum on the current record in the subform doesn't make any sense, so I assume you mean something else. In any event, if you need to use criteria, you'll have to use DSum, and part of the criteria will have to be the primary key value of the parent record.
    Charlotte

  10. #10
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Setfocus (A2000)

    Hi Charlotte, great work you're doing here.

    In the footer of the subform, I need to total [TG] & [TT].
    This is quite easy as in =Sum([TG]) etc, the main form doesn't really play a part at this stage.
    The fields in the sub are : -

    [EstimateNo] Primary
    [Supp] Primary
    [Operative]
    [Operation]
    [TG] Time given
    [TT] Time taken

    the Operation can be 3 text values. "Paint" "Body" "Fit"

    The operatives are capable of all these 3 alternatives. Operation is a lookup combo.

    As I said I can total up all the TG & TT quite easily.
    I want to break these totals up somehow.

    Using the EstimateNo & Supp, I want to total each group "Paint" "Body" "Fit" so on the main form I can reference this.

    The DSum expression I used before pulls the total from the table for ALL records that match the criteria. I don't want this to happen.

    I suppose my expression should be something like: -

    Display the total for "Paint"
    Display the total for "Body"
    Display the total for "Fit" using the current subform EstimateNo & Supp

    The attached pic is in form view, you see we are on EstimateNo 15012 / 0.
    0 is the Supp

    You'll see paint, body, fit which was selected from the operation combo.
    Two operatives could have done the same operation, it doesn't matter, whats important is the "Paint" "Body" "Fit"

    I've tried to make this clear Charlotte, Don't know if I have, Let me know.

    Dave
    Attached Files Attached Files

  11. #11
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Setfocus (A2000)

    As I said before, the only way to do this without creating a bunch of code to open and close recordsets is to use the DSum function. Have you tried using it with the Estimate number and Operation criteria?

    DSum("[TG]","LABOUR BOOKING","[OPERATION]='PAINT' AND [ESTIMATENO] = " & Me![EstimateNo])
    Charlotte

  12. #12
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Setfocus (A2000)

    Charlotte.

    I've taken a different approach to this which is as effective.
    I created a query which I summed on the TG & TT fields.
    From their, set the criteria to the main form : - Forms!frmLabourOperations!EstimateNo.
    Created another subform from the query.

    I would have liked to use the DSum in several unbound texts but couldn't make it work.

    thanks all for the help.

    Dave

Posting Permissions

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