Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 13th, 2006, 02:38 PM
Authorized User
 
Join Date: Apr 2005
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default Continuous form / SetFocus help

I have an Invoice form that is formatted to continuous form view. The below event procedures work well if there is only 1 record. However, with 2 or more records, the SetFocus event moves the cursor to the correct field, but back on the first record. Can I SetFocus within the current record? I have tried without success.


Private Sub UnitPrice_AfterUpdate()
    [SubTotal] = RoundCC([Multiplier] * [UnitPrice])
    Me.Requery
    SurchargePercent.SetFocus
End Sub



Private Sub SurchargePercent_AfterUpdate()
    [SurchargeAmount] = RoundCC((Nz([Multiplier]) * Nz([UnitPrice]) * Nz([SurchargePercent])) / 100)
    Me.Requery
    CommonComments.SetFocus
End Sub


Thanks in advance for your help.


D. Bartelt
__________________
D. Bartelt
 
Old February 13th, 2006, 03:02 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi ya D!

In each of your after update events, you need to set the record number to a variable. Once that's done, after your requery, use the docmd.gotorecord offset
then setfocus to the field

Private Sub UnitPrice_AfterUpdate()
    myrecnum = me.currentrecord
    [SubTotal] = RoundCC([Multiplier] * [UnitPrice])
    Me.Requery
    docmd.gotorecord,,,myrecnum
    SurchargePercent.SetFocus
End Sub

HTH,

Kevin

dartcoach
 
Old February 13th, 2006, 03:43 PM
Authorized User
 
Join Date: Apr 2005
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default

How's it going Kev?

Thanks for your reply. I tried what you suggested. When I compile and save all modules, I receive a "Variable not defined" error. I then tried Dim MyRecNum as Interger, as String and as Boolean. None of them work. The cursor either goes to the next record or to the previous record. Do you have any more suggestions?

Don

D. Bartelt
 
Old February 13th, 2006, 03:49 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Don,

Dim MyRecNum as integer.

Are you still using the requery? Also, are these records new?

Kevin

dartcoach
 
Old February 13th, 2006, 03:56 PM
Authorized User
 
Join Date: Apr 2005
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Kevin,

I believe that i have solved it. I am trying to requery the entire form whem all I needed to requery was the SubTotal and SurchargeTotal fields.

New codes are:

Private Sub SurchargePercent_AfterUpdate()

    [SurchargeAmount] = RoundCC((Nz([Multiplier]) * Nz([UnitPrice]) * Nz([SurchargePercent])) / 100)
    Me!SurchargeTotal.Requery

End Sub

Private Sub UnitPrice_AfterUpdate()

    [SubTotal] = RoundCC([Multiplier] * [UnitPrice])
    Me!LineSubTotal.Requery

End Sub


Thanks again:)

D. Bartelt
 
Old February 13th, 2006, 03:59 PM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Don,

Glad you got it.

Take care,

Kevin

dartcoach





Similar Threads
Thread Thread Starter Forum Replies Last Post
SetFocus on a textbox when form load snowydust VB How-To 9 February 10th, 2017 12:43 AM
colour continuous form palmer Access 4 July 29th, 2009 03:26 AM
Continuous Form - Images nilkanth Access 9 July 29th, 2009 02:30 AM
Filter Records in a continuous form darrenb Access 2 June 1st, 2007 06:50 AM
Write Conflict in continuous Form pinkandthebrain Access 2 July 18th, 2003 11:16 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.