Results 1 to 12 of 12
  1. #1
    ts_hunter is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2014
    Posts
    30

    Form loads with no current record


    I am releatively new to Access, but have a programming background, so I bet I am just missing some small detail. I have a table Plan_Settings that I have a edit form made for (frmEdit). I have another form frmMain that lists the records and when I double click on a record I want to bring it up in the frmEdit form so I can make changes.

    I did some digging here and found how to put an embedded macro on the doubleclick event. Below is the macro I have to load the record I double click on into my frmEdit. The form comes up, but there is no record loaded. Perhaps my Where Condition is wrong? Plan_ID is the primary key.

    Click image for larger version. 

Name:	macro1.JPG 
Views:	25 
Size:	17.5 KB 
ID:	15068

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    The does look appropriate. Although not sure the first = sign is needed.

    I don't use macros, only VBA which would be (assumes Plan_ID is number type):

    DoCmd.OpenForm "frmEdit", , , "Plan_ID=" & Me.Plan_ID, acFormEdit, acDialog
    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.

  3. #3
    ts_hunter is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2014
    Posts
    30
    Quote Originally Posted by June7 View Post
    I don't use macros, only VBA which would be (assumes Plan_ID is number type):

    DoCmd.OpenForm "frmEdit", , , "Plan_ID=" & Me.Plan_ID, acFormEdit, acDialog
    Thanks for the info. I saw that command also, but couldn't get the syntax quite right. I will try the code above in the morning and report back.

  4. #4
    ts_hunter is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2014
    Posts
    30
    OK, I created a new form and added a double click event to run the following code:


    Private Sub Plan_Name_DblClick(Cancel As Integer)
    DoCmd.OpenForm "frmEdit", , , "Plan_ID=" & Me.Plan_ID, acFormEdit, acDialog
    End Sub

    Now when I double click on one of my records to bring it up in the frmEdit, I get the following prompt for a parameter:

    Click image for larger version. 

Name:	form2.JPG 
Views:	18 
Size:	25.2 KB 
ID:	15069

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    What happens when you open frmEdit in form view using the Navigation Pane? Do you get the same missing paramater message. What happens if you open the query that is the recordsource for frmEdit?

  6. #6
    ts_hunter is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2014
    Posts
    30
    Quote Originally Posted by ItsMe View Post
    What happens when you open frmEdit in form view using the Navigation Pane? Do you get the same missing paramater message. What happens if you open the query that is the recordsource for frmEdit?
    When I open the frmEdit from the navigation pane, it comes up empty, and then I can add records. There is no Query associated for frmEdit - do I need one?

  7. #7
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    No you do not need a query. Just trouble shooting. Open your form frmEdit in design view and check the properties of the form. In the property sheet, in the Data Tab there is a field for Data Entry. If this property is Data Entry = Yes, you will not be able to use WHERE Criteria when opening. Set it to No. If it is still opening without any records showing then check the formas recordsource.

    I usualy use a docmd like this to open "filtered" results. I think acFormEdit is default and is not necesary but, I do not believe it will overide the property Data Entry.

    DoCmd.OpenForm "frmEdit", acNormal, , "Plan_ID=" & Me.Plan_ID

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,633
    What is the RecordSource of frmEdit?
    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.

  9. #9
    ts_hunter is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2014
    Posts
    30
    Quote Originally Posted by June7 View Post
    What is the RecordSource of frmEdit?
    I created a new query that selects all the fields from Plan_Settings, that is what the Recordsource is set to now.

  10. #10
    ts_hunter is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2014
    Posts
    30
    I have attached a copy of the db.TESTDB.zip

  11. #11
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    You Plan_ID field is of Text data type, so the code is a little different when you concatenate text variables into your string.

    DoCmd.OpenForm "frmEdit", , , "Plan_ID = '" & Me.Plan_ID & "'", acFormEdit, acDialog

    Suggest using Autonumber as PK's and Long Integer as FK's

  12. #12
    ts_hunter is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2014
    Posts
    30
    Quote Originally Posted by ItsMe View Post
    You Plan_ID field is of Text data type, so the code is a little different when you concatenate text variables into your string.

    DoCmd.OpenForm "frmEdit", , , "Plan_ID = '" & Me.Plan_ID & "'", acFormEdit, acDialog

    Suggest using Autonumber as PK's and Long Integer as FK's
    BINGO! Thanks so much.

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

Similar Threads

  1. Add Record from Current Form to a Table
    By Smtz in forum Access
    Replies: 1
    Last Post: 08-26-2013, 03:49 PM
  2. Form loads blank
    By sweetiepie in forum Forms
    Replies: 5
    Last Post: 06-07-2012, 02:34 PM
  3. list box not updating until form loads
    By cowboy in forum Forms
    Replies: 3
    Last Post: 03-12-2010, 12:02 PM
  4. Replies: 3
    Last Post: 02-28-2010, 11:05 PM
  5. Open form to current record
    By rbpd5015 in forum Access
    Replies: 1
    Last Post: 08-28-2009, 01:53 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