Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2003
    Thanked 0 Times in 0 Posts

    Passing value to new form (2000)

    I have a command button on a form that brings up another form (Resolutions Vote Color) with the records where the CtyBoardMtgID is the same. I want to modify this button so, in addition to this, if there are no records with that CtyBoardMtgID, it would bring up the Resolutions Vote Color form to add a new record and carryover the CtyBoardMtgID to this form. The code works if there are records with that CtyBoardMtgID, but doesn

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 31 Times in 31 Posts

    Re: Passing value to new form (2000)

    If the form "Resolution Vote Color" is not open already, the instruction DoCmd.GoToRecord acDataForm, stDocName, acNewRec (with stDocName = "Resolution Vote Color") should cause an error message. the instruction [CtyBoardMtgID] = varcb after this still operates in the calling form, not in "Resolution Vote Color". What you should do is open the form, set its data mode to adding new records and pass varcb as OpenArgs, the last argument of DoCmd.OpenForm. In the OnLoad event of the called form, set CtyBoardMtgID.

    In the calling form:

    If rst.NoMatch Then
    varcb = Me!CtyBoardMtgID
    RunCommand acCmdSaveRecord
    stDocName = "Resolution Vote Color"
    DoCmd.OpenForm stDocName, , , , acFormAdd, , varcb

    In the OnLoad event of "Resolution Vote Color":

    If Not IsNull(Me.OpenArgs) Then
    [CtyBoardMtgID] = OpenArgs
    End If

    <img src=/w3timages/blueline.gif width=33% height=2>

    Other notes:
    <UL><LI>Use CurrentDb instead of DBEngine.Workspaces(0).Databases(0).
    <LI>Use RunCommand acCmdSaveRecord instead of the antiquated DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70.
    <LI>Follow a VBA for Access course, or study a good book on programming in Access. See the replies to <post#=251186>post 251186</post#> for suggestions.[/list]

Posting Permissions

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