[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1061
  • Last Modified:

Microsoft Access 2013 Open form to a specific record not working

I have a form frmaddclient. I need to add a client name, address and other democraphics to  that record. Then I want to allow user to open frmeditclient with additional information.  I open frmaddclient with the add mode. When I just use the wizzard it opens frmeditclient to the first client in the recordset. I wonder if it is not working because some how the database is not recognizing the new record. I use RunCommand acCmdSaveRecord before I try to open the second form. Is there something I am missing. Thanks for the help.
0
marlind605
Asked:
marlind605
  • 8
  • 6
1 Solution
 
Dale FyeCommented:
we would have to see the code that is opening frmAddClient and calling your frmEditClient to be sure.

It sounds like those steps should work correctly.  Normally, instead of :

RunCommand acCmdSaveRecord

I simply set the forms Dirty property to False, and then open the 2nd form

me.dirty = false
strCriteria = "[ClientID] = " & me.clientID
docmd.OpenForm "formname", acNormal, , strCriteria,,acdialog
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Also, there's generally no need to have Add and Edit forms. Just put all the information needed for a specific entity (like your Client) on a single form, and then allow the user to Add or Edit from there.
0
 
marlind605Author Commented:
I think I see what is going on now. The formname has a recordsource loaded in the form and when I do fyed's suggestion it opens as new. Can I check to see if my frmaddclient is open and if it is filter frmname with that new record close the frmaddclient? Scott, I thought of making certain tabs and controls dissapear if the new record button is selected but this is a new gig for me and not sure how much they will let me change things.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Dale FyeCommented:
Check the DataEntry property of the frmEditClient.  If that property is set to Yes, the form will only open to a new record.
0
 
marlind605Author Commented:
I changed it to yes and it still comes in as new.
0
 
Dale FyeCommented:
NO, you don't want it to be Yes, it should be "No".

What code is being used to open frmEditClient?

Can you open that form in design view, then display the data tab of the properties dialog, and take a screen shot of the properties and post that image here so we can see what that looks like?

It would be helpful if you could create a sanitized (no personal or proprietary data) database with these three forms and the associated tables and queries and post it here.  

Make sure you either remove all records or fields that contain phone numbers, addresses, SSN, or any other personally identifiable information.
0
 
marlind605Author Commented:
The record source on frmname = SELECT * FROM clients WHERE 1=1;  where clients is a table
0
 
marlind605Author Commented:
The user requested to be able to directly go from the Add New Form, to an Edit form name formEditClient. I put a msgbox and it is picking up the correct new ID.

strCriteria = "Clients_ID = " & Me.Clients_ID
MsgBox strCriteria
DoCmd.OpenForm "FormEditClient", acNormal, , strCriteria, , acDialog
0
 
Dale FyeCommented:
what is the recordsource for FormEditClient?
0
 
marlind605Author Commented:
frmeditclient recordsource is record source on frmname = SELECT * FROM clients WHERE 1=1;  where clients is a table
0
 
Dale FyeCommented:
The WHERE clause is redundant, if you are not going to sort that table , then there is really no need to use the query at all, simply set the RecordSource to : Clients

But that still is not what is causing this problem.  Can you take that screenshot of the Data tab on the properties dialog with FormEditClients open and selected.
0
 
marlind605Author Commented:
Thanks for the help again. I did not create this database.  Just trying to make improvements the client has requested.
datatab.JPG
0
 
Dale FyeCommented:
Can you post the entire code you are using to open this form?
0
 
marlind605Author Commented:
From the form frmaddclient the user fills out the name and the cmdedit button because visible. They will save the record and tblresource is populated with a resource id (No issues here).
When the frmeditclient is selected from the main menu the user will use a search feature that will find the proper record. I have added a myclientid field in the frmeditclient and tried the to open the filter and I get the same results as I do when I use the prior existing tbID field that contains the Client_ID.   Hope this helps.

Dim strCriteria As String
    Call Save_The_Record
   
    Dim rs As DAO.Recordset
        Set rs = CurrentDb.OpenRecordset("tblresource", dbOpenDynaset, dbSeeChanges)
        rs.AddNew
        rs!OLFC_Clients_TL_Client_ID = Me.comboresource
        rs.Update
        rs.Close
     
strCriteria = "tbID = " & Me.Clients_ID
MsgBox strCriteria
DoCmd.OpenForm "Frmeditclient", acNormal, , strCriteria, , acDialog
0
 
marlind605Author Commented:
Found out there was a command that was calling the previous record on the frmedit form that is what prevented this from working. Thanks for the help
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 8
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now