Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Edit form does not display all fields in a record but the ID 1

Status
Not open for further replies.

ciskris

Programmer
Jun 22, 2001
13
0
0
US
I have a search form where you select an ID from a drop-down and the command buttons(for edit forms) below the drop-down are enabled if that ID is contained in the table that is queried for each of the edit form buttons. When you click on an edit form button the ID becomes a global variable which is called by the edit forms load event after the button is clicked. Once the edit form is loaded and displayed the ID is displayed in the ID text box on the form but no other fields on the form come with it. How would I pull the fields up once the ID is passed to the edit form? Any suggestions?
 
Hi!

I'm going to make one assumption here, that you are using the openform method to open the edit forms. If so, use this code:

Dim strCriteria As String

strCriteria = "YourIDField = '" & cboIDBox & "'"
DoCmd.OpenForm "YourForm", , , strCriteria

This will automatically open the form with only the records that contain the ID. Of course you will need to substitute the actual names of fields, controls and forms as found in your Db. One last note, I assumed(that makes two) that your ID field is text, if it is numerical then:

strCriteria = "YourIDField = " & cboIDBox

will work.

hth
Jeff Bridgham
 
I am using the code:
txtContractID = cboProvider
DoCmd.OpenForm "editform"
DoCmd.Close acForm, "currentform"
This code is in the click event for the button on the search form.

On the edit form I don't have an open event but a form_load where I Me.AllowEdits = True and set all fields Locked property to False and then the code:
DoCmd.GoToRecorde , , acNewRec
ContractID = txtContractID
And then I add the code to set all fields Locked property to True so when the form is displayed it is locked until an Edit button is clicked.
That is the code that I have to pull over the ID. The ID field is text because it is actually a social security number. I did try a version your suggested Openform code but it did not work. Will it work with my code above?
 
Hi!

I think I may need a little explanation. I thought that, when you go to an edit form, you will edit the information in an existing record. If that is the case, then you shouldn't be going to a new record as you do in the code you submitted. If there are existing records then comment out all of the code in the load event of your edit form and use the code I gave you to open the edit form from the click event of the search form go ahead and retain the code you have and just add the extras and make the needed changes to what you have. If you are adding a new record, then I don't understand why you expect to see information and any of the other controls, since that information would not exist in your database yet. Let me know if I am way off base here.

Jeff Bridgham
 
Sorry about the confusion. That code was given to me by a coworker trying to help me with the solution. I am trying to pull up an existing record. I will add your code to what I have and take out the acNewRec. Can I still keep the code for locking the records and unlocking them?
 
Thanks Jeff for your code suggestion. I added it to my search form and it worked. Now when I open up an edit form I see all of the fields that have been filled in for the ID I was searching on. I can finally finish up my database and train the users on it. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top