Results 1 to 6 of 6
  1. #1
    DCTerp is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Jan 2019
    Posts
    7

    When Button is pressed, form should open to specific record, from a combo box - HELP

    Hey there,

    I'm fairly new to Access programming, and I'm still learning.



    Currently, I have a form that allows for viewing of a record, but not editing (frmViewProvider). A Combo box is used to chose the record being viewed. I have a button that, when pressed, I'd like to open an another form (frmEditProvider) but when pressed, goes back to the first record in the data set, rather than the record that was recently viewed. I'd like to for the button to open the record currently being shown in the Combo Box. Is there a way to do that? (I'm sure there is, I'm just not aware of it)

    Thanks, all!

    J.
    Click image for larger version. 

Name:	DB.PNG 
Views:	13 
Size:	33.0 KB 
ID:	36810

  2. #2
    DCTerp is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Jan 2019
    Posts
    7
    I found this, but when I click on my button, I get a dialog box asking for a parameter:

    DoCmd.OpenForm "frmEditProvider", , , "Label3 = '" & Me.SelectProvider & "'"

  3. #3
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    You need to change Label3 to the name of the data field that you are searching. This is typically a unique primary key field with a numerical datatype and not a string datatype as is implied by the code you showed in post 2.

    Can you post the SQL query or row source for the SelectProvider combobox as well as the table/query structure of the frmEditProvider record source?

  4. #4
    DCTerp is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Jan 2019
    Posts
    7
    Here's the row source for the SelectProvider Combobox: SELECT [tblProviders].[Provider ID], [tblProviders].[Business Name] FROM tblProviders;

  5. #5
    kd2017 is offline Well, I tried at least.
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1,142
    Ok, your command should look something more like this:
    Code:
    DoCmd.OpenForm "frmEditProvider", , , "[Provider ID] =" & Me.SelectProvider
    Make sure the Combobox's Bound Column property is set to 1.

    I'm still making assumptions here, I'm assuming Provider ID is numeric and that it's also available to the record source of the form. If that doesn't work we'll need to see your table/query record source for this form.

    BTW, it's best practice not to have spaces in your field names. Instead of [Provider ID] and [Business Name] you should change them to [ProviderID] and [BusinessName] or [Provider_ID] and [Business_Name] or something to that effect. Also, make sure you don't use symbols in names either, just letters, numbers and underscores.

  6. #6
    DCTerp is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Jan 2019
    Posts
    7
    That worked! Thanks!

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

Similar Threads

  1. Replies: 6
    Last Post: 06-19-2018, 03:38 PM
  2. Replies: 6
    Last Post: 05-07-2014, 11:26 AM
  3. Replies: 2
    Last Post: 10-08-2012, 12:39 PM
  4. Replies: 3
    Last Post: 04-17-2012, 03:26 PM
  5. Replies: 3
    Last Post: 01-14-2010, 08: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