Editing Record in a form (1 Viewer)

BruceMalone

Registered User.
Local time
Today, 08:15
Joined
Dec 17, 2019
Messages
16
Hi. New to access and I have created a database to track employees. I have created a table and a form to input the worker data. I am able to create new records and have them show up in the table without a problem. Now I am trying to find a way to create a button to edit a selected record. There seems to be no macro for editing a record. I can edit in the table directly but would like to do so in the form where all info is organized properly.



For this to happen, can I use the existing form I used to add the new entry or would I need a new form? What commands are available to do what I am trying to do? Thanks in advance.
 

vba_php

Forum Troll
Local time
Today, 10:15
Joined
Oct 6, 2019
Messages
2,880
hello Bruce,


Data can be edited and added in the same form. A form that can do such things is called *bound*. Google the word along with *ms access form* and you can educated yourself regarding the issue. Users should never edit data in tables anyway, so you're off to a good start. one thing to note is that a lot of developers (like me) will use 1 main form for viewing purposes and then issue a popup form on top of the main one when a user clicks a button for the purposes of editing the record or adding new ones.
 

bob fitz

AWF VIP
Local time
Today, 16:15
Joined
May 23, 2011
Messages
4,719
Bruce

Is the forms "Allow Edits" property set to YES
 

BruceMalone

Registered User.
Local time
Today, 08:15
Joined
Dec 17, 2019
Messages
16
Thanks for the replies. Yes the edit is set to YES. Iv been looking around and saw a video that instructs to add the following condition on the openform macro:


="[First Name]"=&[First Name]


This is when I click on the table and its supposed to open up the record in the form. I cant seem to get it to work. I get a parameter error while inputting this code. If i simply put the condition to =First Name, it opens the first record but no the one that I click/select.
 

vba_php

Forum Troll
Local time
Today, 10:15
Joined
Oct 6, 2019
Messages
2,880
i'll keep an eye on this Bruce. surely an AWF VIP will know how to help you.
 

Gasman

Enthusiastic Amateur
Local time
Today, 16:15
Joined
Sep 21, 2011
Messages
14,235
You have Data Entry set to Yes.
This property is misleading as it means you can only add new records.?
You could set this to Yes/No with VBA as you need to.

I have set it to No in the form and added Navigation Buttons.

Your form is bound to the table, so all you have to do is locate the correct record.
To add a new record you would use the * next to the navigation buttons.

That is the Access default method. If you want something different then you have to role your own. I tend to use the defaults where I can when it is only just for me, but when I was working other users were quite comfortable using the default methods.?

I have a similar setup, but with an Emulated Split form to be able to easily locate the record I wish to edit.

The next step would be to filter or create a form to search the table for the required record.

HTH
 

Attachments

  • workerdatabasetest.accdb
    712 KB · Views: 89

bob fitz

AWF VIP
Local time
Today, 16:15
Joined
May 23, 2011
Messages
4,719
Bruce

I have made a number of changes to your db.

Hopefully, the form that opens will be close to what you are trying to achieve.

Please post back if you have any questions.
 

Attachments

  • workerdatabasetest (1).accdb
    580 KB · Views: 89

BruceMalone

Registered User.
Local time
Today, 08:15
Joined
Dec 17, 2019
Messages
16
Bruce

I have made a number of changes to your db.

Hopefully, the form that opens will be close to what you are trying to achieve.

Please post back if you have any questions.


Thank you SOOO much!! I'ts very close to what I need. I will check it out and play around and let you know if any questions. Thanks again!!
 

bob fitz

AWF VIP
Local time
Today, 16:15
Joined
May 23, 2011
Messages
4,719
Thank you SOOO much!! I'ts very close to what I need. I will check it out and play around and let you know if any questions. Thanks again!!
You will notice that I have:
Changed the names of some objects
Changed how the Agent name is stored in the tblWorkerData table. I would recommend that you change the way you store "Payment Status" and "Interview Status" as well.
 

vba_php

Forum Troll
Local time
Today, 10:15
Joined
Oct 6, 2019
Messages
2,880
Thank you SOOO much!! I'ts very close to what I need. I will check it out and play around and let you know if any questions. Thanks again!!
ahhhhh....yet another success story chalked up for access world forums. :)
 

BruceMalone

Registered User.
Local time
Today, 08:15
Joined
Dec 17, 2019
Messages
16
You will notice that I have:
Changed the names of some objects
Changed how the Agent name is stored in the tblWorkerData table. I would recommend that you change the way you store "Payment Status" and "Interview Status" as well.


I do have one question, in the find drop box, its set to last name + first name. I realize I could have multiple workers with the same last name and it doesnt seem to list them all. How would I be able to use a different field in the dropdown thats a bit more uniqe for example pp number? I looked at the code and seems it should show that number but it doesnt?


Edit: I think I know why pp is not showing, I tried the wizard and see a option to hide keycolumn. How can this be unhidden?


DoCmd.SearchForRecord , "", acFirst, "[PassportNumber] = " & "'" & Screen.ActiveControl & "'"
Me.cboFind = Null
 
Last edited:

bob fitz

AWF VIP
Local time
Today, 16:15
Joined
May 23, 2011
Messages
4,719
Edit: I think I know why pp is not showing, I tried the wizard and see a option to hide keycolumn. How can this be unhidden?
Take a look at the "Column Widths" property of the combo box. The first column(PassportNumber) is hiddden because the first column width is set to 0. Increase this to something like 2 to show the Passport Number.
 

BruceMalone

Registered User.
Local time
Today, 08:15
Joined
Dec 17, 2019
Messages
16
Take a look at the "Column Widths" property of the combo box. The first column(PassportNumber) is hiddden because the first column width is set to 0. Increase this to something like 2 to show the Passport Number.


Thanks again!
 

Users who are viewing this thread

Top Bottom