Results 1 to 2 of 2
Thread: Passing value to new form (2000)
2003-05-08, 19:22 #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
2003-05-08, 20:13 #2
- Join Date
- Mar 2002
- Thanked 28 Times in 28 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
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
<img src=/w3timages/blueline.gif width=33% height=2>
<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]