Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 13th, 2006, 02:38 PM
Authorized User
 
Join Date: Apr 2005
Location: , , USA.
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
Reply With Quote
  #2 (permalink)  
Old February 13th, 2006, 03:02 PM
Friend of Wrox
 
Join Date: Jan 2005
Location: Kansas City, Missouri, USA.
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
Reply With Quote
  #3 (permalink)  
Old February 13th, 2006, 03:43 PM
Authorized User
 
Join Date: Apr 2005
Location: , , USA.
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
Reply With Quote
  #4 (permalink)  
Old February 13th, 2006, 03:49 PM
Friend of Wrox
 
Join Date: Jan 2005
Location: Kansas City, Missouri, USA.
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
Reply With Quote
  #5 (permalink)  
Old February 13th, 2006, 03:56 PM
Authorized User
 
Join Date: Apr 2005
Location: , , USA.
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
Reply With Quote
  #6 (permalink)  
Old February 13th, 2006, 03:59 PM
Friend of Wrox
 
Join Date: Jan 2005
Location: Kansas City, Missouri, USA.
Posts: 471
Thanks: 0
Thanked 1 Time in 1 Post
Default

Don,

Glad you got it.

Take care,

Kevin

dartcoach
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 11:59 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.