Results 1 to 8 of 8
  1. #1
    focosi is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    97

    passing openArg to a listbox on other form

    On the first form I have a button with the following OnClick event :

    Private Sub Rispondi_Click()
    acbReceiveMail
    On Error GoTo Err_Rispondi_Click
    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "frmSendMail"
    DoCmd.OpenForm stDocName, , , stLinkCriteria, , , Me.txtFrom
    Exit_Rispondi_Click:
    Exit Sub
    Err_Rispondi_Click:
    MsgBox err.Description
    Resume Exit_Rispondi_Click
    End Sub


    On the form opened upon click ("frmSendMail") I am trying to populate the "cboTo" combobox with the "txtFrom" value from first form. In the OnLoad event I have written :

    Private Sub Form_Load()
    Me.cboTo = Me.OpenArgs
    End Sub

    Anyway after clicking the button that should open "frmSendMail" I get a popup saying : "An expression you entered is the wrong data type for one of the arguments" (run-time error '2498')


    Any hint ??

  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,127
    Does it highlight a line? If not, temporarily comment out the "On Error..." line and run the code, which should take you to the offending line.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    focosi is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    97
    I have commented out the "On Error ..." line and here is the line that the debugger highlights :

    DoCmd.OpenForm stDocName, , , stLinkCriteria, , , Me.txtFrom

    Any hint ?

  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,127
    I don't see anything wrong with that offhand. Does frmSendMail open without error if you open it directly? It could be an error there.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    focosi is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    97
    Yes, frmSendMail opens without error if I open it directly (I use it to send the original message, but I cannot reopen it when I click the reply button on the frmReceiveMail), and from the highlighted line it seems that the form is not able to pass the argument.....

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,127
    Can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    focosi is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    97
    actually not cause there are too many sensitive data (medical records).
    Anyway I am attaching the sample database from the CookBook. You just have to add a "Reply" button to "frmReceiveMail" in order to try open the frmSendMail and populate the "cboTo" control with the sender of previous mail (in the case you have no ULS database where to import this form, you'll need to modify the data in "tblMessage" in order to receive a message :-)
    Before you can try it, you'll need to link the data tables from 10-04be.MDB to 10-04fe.MDB.
    Thanks for help!

  8. #8
    randman1 is offline Novice
    Windows XP Access 2003
    Join Date
    Dec 2009
    Posts
    25
    OpenArgs is a String data type. What type is the bound column for the listbox? Normally, all of my list and combo boxes are multi column having the first column hidden. I usually use something like DLookup("IdField", "Table", "TextField = " & Me.OpenArgs) to obtain the ID.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. passing value to new second form
    By englek in forum Forms
    Replies: 2
    Last Post: 08-08-2011, 01:40 PM
  2. passing variable from modal form to main form
    By crowegreg in forum Forms
    Replies: 2
    Last Post: 06-03-2011, 05:34 PM
  3. Passing value from one form to another
    By Molly152 in forum Forms
    Replies: 4
    Last Post: 11-16-2010, 11:03 AM
  4. Replies: 1
    Last Post: 03-24-2010, 08:42 AM
  5. Passing a variable to a form
    By cjamps in forum Forms
    Replies: 0
    Last Post: 03-02-2009, 05:32 AM

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