Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    l3111 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    38

    Exclamation OpenArgs problems - FAO pbaldy/ruralguy

    I'm currently trying to use OpenArgs.
    I have one form called frmReferralsDischarges with a RAISENumber field and another form called frmOtherServices. The latter form requires information enterd on th 1st form to be stored in a seperate table but linked to the referral that is recorded in the first form (frmReferralsDischarges).
    Whn in the Referrals frm, i have a cmd button (cmdOtherServices) which opens the Other Services form as a popup. I would like to use the OpenArgs condition to pass over the RAISENumber (and referral autonumber? see NB) On a related note, do the relationships set up in my table play any part here? NB: RAISENumber can be duplicated but a ReferralAutonumber has been assigned to the Referral to be the unique identifer. This field is also in the Other Services table but should also be passed over to retain the linkage between referral and other services.

    PS
    I have used the code provided on http://www.baldyweb.com/OpenArgs.htm
    however when i try and run the code, i get this error


    Compile Error: Invalid Outside Procedure
    and it highlights the section in red
    Dim strOpenArgs() As String

    If Not IsNull(Me.frmOtherServices) Then
    strOpenArgs = Split(Me.frmOtherServices, ";")
    Me.RAISENumber = strOpenArgs(0)
    Me.ReferralAutonumber = strOpenArgs(1)
    Else
    Me.txtOtherInfo = "Unknown"
    End If


    The section highlighted in blue, i haven't changed as I dunno wht to change it to

    ALSO where does this code actually go?!

    l3111, Manchester, UK

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Where exactly to you have that? It would have to be inside a procedure, as demonstrated in the sample db. From the sound of it, you'd want the code behind cmdOtherServices.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    l3111 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    38
    Is using OpenArgs the correct way to go?

    I am unable to open the sample db due to restricitions at work

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    It's one way to go. Depending on what you're doing, you can also do this:

    DoCmd.OpenForm "OtherFormName"...
    Forms!OtherFormName.SomeControlName = Me.SomeControlName
    Forms!OtherFormName.SomeOtherControlName = Me.SomeOtherControlName
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by l3111 View Post
    ALSO where does this code actually go?!

    l3111, Manchester, UK
    The code you posted goes in the OnLoad event of the 2nd form.

  6. #6
    l3111 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    38
    Ok so i thought i'd fix it....but i've not

    whn i open my referral form in Add mode, enter all the information req'd and then click the Other Sevices command button (cmdOtherServices) it does not move the RAISENumber over.....

    any suggestions on where i'm goin wrong?!



    Many thanks

    l3111, Manchester, UK

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    If Not IsNull(Me.frmOtherServices) Then
    ...should read...
    If Not IsNull(Me.OpenArgs) Then
    strOpenArgs = Split(Me.OpenArgs, ";")

  8. #8
    l3111 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    38
    Thank You!!
    It now does something, however its not copying over the RAISENumber.
    This is my code:

    Dim strOpenArgs() As String
    If Not IsNull(Me.OpenArgs) Then
    strOpenArgs = Split(Me.OpenArgs)
    Me.RAISENumber = strOpenArgs(0)
    Else
    Me.RAISENumber = "0"
    End If

    The section in red is where I feel my problem lies because when I do open the Other Services form, it enters a 0 in the RAISENumber field, rather thn pulling the RAISENumber from the orignal form....

    Really appreciate your help!!!

    l3111, Manchester, UK

  9. #9
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Change it to: Me.RAISENumber = 0

  10. #10
    l3111 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    38
    Buuuuut it should never have to enter a zero, there will always be a RAISENumber to enter.

    However, its not picking up the RAISENumber still

  11. #11
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Then you are not filling the OpenArgs argument first. What does the code look like that opens this 2nd form?

  12. #12
    l3111 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    38
    the code that is behind the command button is this

    Private Sub cmdOtherServices_Click()
    On Error GoTo Err_cmdOtherServices_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmOtherServices"

    stLinkCriteria = "[RAISENumber]=" & Me![RAISE Number]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

    DoCmd.OpenForm "frmOtherServices"
    Forms!frmReferralsDischarges.RAISENumber = Me.RAISENumber

    Exit_cmdOtherServices_Click:
    Exit Sub

    Err_cmdOtherServices_Click:
    MsgBox Err.Description
    Resume Exit_cmdOtherServices_Click

    End Sub

  13. #13
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try the following:
    Code:
    Private Sub cmdOtherServices_Click()
       On Error GoTo Err_cmdOtherServices_Click
       Dim stDocName As String
       Dim stLinkCriteria As String
       stDocName = "frmOtherServices"
       '-- Replace the next 4 lines
       '   stLinkCriteria = "[RAISENumber]=" & Me![RAISE Number]
       '   DoCmd.OpenForm stDocName, , , stLinkCriteria
       '   DoCmd.OpenForm "frmOtherServices"
       '   Forms!frmReferralsDischarges.RAISENumber = Me.RAISENumber
       '-- With...
       DoCmd.OpenForm stDocName, , , , , , Me.[RAISE Number]
    
    Exit_cmdOtherServices_Click:
       Exit Sub
    Err_cmdOtherServices_Click:
       MsgBox Err.Description
       Resume Exit_cmdOtherServices_Click
    End Sub

  14. #14
    l3111 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    38
    MAJOR PROBLEM!!!

    When users add a referral to my database, and then choose the Other services form, yes the RAISE number moves over...however the information is not saved under that number on the table the form is built from....and every time that form is opened it opens the same information, rahter than a blank form. this form needs to be unique to the referral, but at the moment no data is being saved!!! NEED HELP FIXING THIS PLEASE....how do I upload my db here for your invaluable assistance!!!!1

    l3111, Manchester, UK

  15. #15
    l3111 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    38
    Also, I need the OpenArgs to copy the Referral Autonumber over i've changed the code to this:

    Private Sub Form_Load()
    Dim strOpenArgs() As String
    If Not IsNull(Me.OpenArgs) Then
    strOpenArgs = Split(Me.OpenArgs, ";")
    Me.RAISENumber = strOpenArgs(0)
    Me.ReferralAutonumber = strOpenArgs(1)
    Else
    Me.RAISENumber = 0
    Me.ReferralAutonumber = 0
    End If

    But it is highlighting it as not working......major disaster now, as this has to be fixed today :/

    Thank you for all your help, you've been ace, pleaaaaaase help agen?

    l3111, Manchester, UK

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Showing OpenArgs in a Report.
    By SIGMA248 in forum Programming
    Replies: 2
    Last Post: 04-01-2011, 11:57 AM
  2. problems please help
    By stryder09 in forum Access
    Replies: 1
    Last Post: 02-15-2011, 02:24 PM
  3. Opening a form with openargs and things
    By mwabbe in forum Forms
    Replies: 5
    Last Post: 09-29-2010, 11:01 AM
  4. Several problems
    By Bergh in forum Access
    Replies: 1
    Last Post: 05-30-2010, 03:56 AM
  5. OLE problems how to fix
    By miziri in forum Access
    Replies: 7
    Last Post: 04-29-2010, 06:18 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums