Results 1 to 6 of 6
  1. #1
    jamedadi is offline Novice
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    3

    Passing parameter between forms

    Hi



    I have create a Table named as "Student", with 3 fields: ID, stdName, and stdField.

    I also have created a Query named as "stdQuery". This query return the stdField of a given stdName . Using the SQL language, it can be written as:
    Select stdField from Student where stdName = 'John' (for example)

    In the following, I have created a Form named as "studentField". To create this form, I have used "Form wizard" to map the form to "stdQuery". Up to now, everything is fine.

    In the following, I have defined a second form, namely "studentName". This form contains a comboBox which presents the names of the students. I want that when choosing the name of a student in the comboBox, its field is presented in "studentField". Therefore, I have written the following code in the on_click function of the comboBox of "studentName":

    DoCmd.OpenForm "studentField", , , "stdName = " & combo0.selText

    But when selecting a name in "studentName", it asks for a stdName as if I don't pass it to "studentField".

    Cloud anyone please help me about the problem?

  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
    If the form is based on that query, it doesn't have that field in the SELECT clause, so not available for the wherecondition.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Additionally, ff the student name the Bound Field of the combo0 Combobox? If not, which column does it appear in, keeping in mind that going from left to right, the 1st column is Column(0), the 2nd column is Column(1), etc.

    selText is the wrong property to be using here. If the student name is the Bound Field, you'd simply use

    Me.combo0.Value

    or, even simpler

    Me.combo0

    From the name, I assume that stdName is just that, a name, i.e. Text. If that is correct, the Where part of the command would be

    "stdName = '" & Me.combo0 & "'"

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    jamedadi is offline Novice
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    3
    Hi
    Thank you for your reply. I have done all of your mentioned notes. Especially:

    Me.combo0.Value
    "stdName = '" & Me.combo0 & "'"

    But it didn't work again!!!

  5. #5
    jamedadi is offline Novice
    Windows 8 Access 2013
    Join Date
    Nov 2013
    Posts
    3
    I even tested the following:
    DoCmd.OpenForm "studentField", , , "stdName= 'John'"

    But it does not work again !!!!

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Show the RowSource of the combobox. Does it include the ID field? Is ID the BoundColumn?

    If you want to provide db for analysis, follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 2
    Last Post: 05-06-2012, 03:52 PM
  2. Passing Parameter from Excel TO Access
    By jo15765 in forum Queries
    Replies: 1
    Last Post: 11-29-2011, 03:28 PM
  3. Parameter Passing
    By Juan4412 in forum Queries
    Replies: 1
    Last Post: 11-21-2011, 10:23 AM
  4. Passing List of Parameter
    By vignes10 in forum Access
    Replies: 3
    Last Post: 09-15-2011, 07:35 AM
  5. Macro passing a parameter
    By SlowPoke in forum Access
    Replies: 1
    Last Post: 09-26-2010, 09:57 PM

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