Wrox Programmer Forums
|
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 May 8th, 2008, 11:29 AM
Authorized User
 
Join Date: May 2007
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default Code help - Form misbehaving

Can someone please tell me what is going wrong with this code. It happens periodically. Even though there is a request on another form in the form of

docmd.openform "frmname"
Forms!frmname.recordsource = strsql
Forms!frmname.requery

However for some reason new record is being activated.


Private Sub Form_Load()

    'set the error trap
    On Error GoTo errorhandler

    'transfer the name of the calling form
    callform = gstrcallingform
    'clear the global calling form holder
    gstrcallingform = ""
    'reset the btnclick
    btnclick = False

    'check if it is a new record
    If Me.NewRecord = True Then
        'it is so reset the risk counter
        priskval = 0
        'set the risk level to low on screen
        Me.productrisk.Value = "Low"

    Else
        'set the risk counter for the appropriate level of risk
        Select Case Me.productrisk.Value
            Case "Low"
                priskval = 1
            Case "Medium"
                priskval = 3
            Case "high"
                priskval = 4
        End Select
    End If

    clock

    'set the option field to show case details
    Me.optfileinspect.Value = 1
    'call the frame selection routine
    Call optfileinspect_AfterUpdate
    'move the focus to the ar firm name
    Me.arfirm.SetFocus


exitld:
    Exit Sub

errorhandler:
    generalerrorhandler Err.Number, Err.Description, ffile, "form_load"
    Resume exitld
    Resume

End Sub

 
Old May 13th, 2008, 06:26 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Can you do this:

Other Form Code:
docmd.openform "frmname"


On Load of the new form:
Me.recordsource = strsql
Me.requery

Declare strsql as a Public variable in a module to pass the value to the opening form. Although I think you can only requery controls, not forms.

Is that where the problem is?

mmcdonal

Look it up at: http://wrox.books24x7.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Refresh form code CrArC Access VBA 1 October 28th, 2006 08:57 AM
Missing +/or Misbehaving Calendar Control Caratman Excel VBA 0 March 5th, 2006 12:57 PM
Database Misbehaving SerranoG Access 2 February 15th, 2005 08:59 AM
InputBox Misbehaving bph Access 10 March 4th, 2004 01:09 PM
Help with Form Code BryanBrassell Access VBA 2 August 18th, 2003 02:34 PM





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