By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,454 Members | 2,633 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,454 IT Pros & Developers. It's quick & easy.

What is happening when I enter this code for a split openargs?

LeighW
P: 73
Hello all,

I have this code running on a command button from the first form

Expand|Select|Wrap|Line Numbers
  1. Private Sub btn_OpenSubEvidence_Click()
  2.  
  3. On Error GoTo Err_btn_OpenSubEvidence_Click
  4.  
  5. Dim stDocName As String
  6.  
  7. stDocName = "frm_SubEvidence"
  8.  
  9. DoCmd.OpenForm stDocName, , , "[SubArgIDFK]=" & Me.[SubArgID], acFormAdd, , Me.[SubArgID] & "|" & Me.[Argument] & "|" & Me.[SubArgument]
  10.  
  11. Exit_btn_OpenSubEvidence_Click:
  12.     Exit Sub
  13.  
  14. Err_btn_OpenSubEvidence_Click:
  15.     MsgBox Err.Description
  16.     Resume Exit_btn_OpenSubEvidence_Click
  17.  
  18. End Sub
And this code running in the on current event of the form which opens:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. If Me.NewRecord Then
  3. Me.[SubArgIDFK] = Split(Me.OpenArgs, "|")(0)
  4.     Me.[Argument] = Split(Me.OpenArgs, "|")(1)
  5.     Me.[SubArgument] = Split(Me.OpenArgs, "|")(2)
  6. End If
  7. End Sub
  8.  
The code has been entered so that when I open the form in Add Mode, the 3 fields I've entered copy across to the new record.

The code actually works for adding a record, however, when you try and open the form in any other way, with a link criteria or the full version it displays no data, just the form header.

The form which is opening is based on a query of a juntion table and the two linked tables. The same method works perfectly for a different form based on a query with a junction table and two linked tables but only has two split openargs using the same code (without the extra field).

I believe the error message when clicking on a command button which opens the form via a link criteria specifies the second code shown above on the opening form as the problem.

Is the code wrong when entering 3 fields for a openargs split? Or is it something else?

Any help would be much appreciated,

Leigh
Jun 28 '12 #1
Share this Question
Share on Google+
6 Replies


LeighW
P: 73
No worries I found out for some reason I had Data Entry set to YES in the form's properties. Much simpler than I thought. Embarrassing!
Jun 28 '12 #2

NeoPa
Expert Mod 15k+
P: 31,186
Also, line #9 indicates to open the form in Data Entry mode anyway, and OpenArgs is only available to the Form_Open() procedure (Once that has completed the passed value is lost).
Jun 29 '12 #3

TheSmileyCoder
Expert Mod 100+
P: 2,321
@ NeoPa.
I believe that you are incorrect. OpenArgs are available as long as the form stay open, and no errors reset the application.
I dont have time to doublecheck just now, however.
Jun 29 '12 #4

NeoPa
Expert Mod 15k+
P: 31,186
That's strange Smiley. Is that for all versions?

I don't like to give out false or unreliable information, but I'm not up to testing just now. Always good to correct me if I get it wrong though.
Jun 29 '12 #5

LeighW
P: 73
It seems to be working fine now since I've changed it. The filter and "acFormAdd" opens up the new record filtered to the ID of the previous form which the user can enter data in and then save. When linking back to the record it remains saved to that previous ID.

I'm using Access 2003! Apparantly it works with both the Form_Current() and Form_Load() events.
Jul 2 '12 #6

NeoPa
Expert Mod 15k+
P: 31,186
Nice one boys :-)

I just tested it and it certainly does keep it available now. I must have picked that up way back when I was using Access 2000 (or even 97 maybe).
Jul 2 '12 #7

Post your reply

Sign in to post your reply or Sign up for a free account.