UPDATE Entry Form

SBBmaster09

Registered User.
Local time
Today, 18:22
Joined
Apr 26, 2013
Messages
92
I have this Update Entry Form.. I have so many fields here but the logic thing to do was, when I open the Update Form, the textfields will display all the data that it can get from the table I've made. Then I can edit those fields and when I press SAVE button, a prompt will show if the data will be saved yes or no? If yes, all fields that has been changed will be saved, and if the field is not changed, it will just save its old data[meaning it will not be lost]. All changes made in the text field will be saved in the table.

Nameof Form: UpdateForm
Table Name: tbl_Roster
Sample TextFields: FieldNameInTheTable[textfieldnameinform]
*Last Name[txtLName], First Name[txtFName]

I use an [EnterpriseID] to locate which data will be updated. Can someone help me with the codes in SAVE button or in Form_Load()

I am also using db As DAO.Database, rst As DAO.Recordset, strSQL As String

I am currently using this codes but doesnt works for me. Help me for easier use or any problem with my coding. Thanks.

SAVE BUTTON
Code:
Private Sub btnSaveEntry_Click()
    Set db = CurrentDb
    Set rst = db.OpenRecordset("tbl_Roster", dbOpenDynaset)
 
    rst.Edit    
    rst("Last Name").Value = txtLName.Value
    rst("First Name").Value = txtFName.Value
    rst.Update
    rst.Close
    db.Close
 
            MsgBox "Your Account has been Updated", vbInformation, "Success"
            'DoCmd.Close acForm, Me.Name
 
 
End Sub

FORM LOAD
Code:
  Private Sub Form_Load()  txtEID.Value = DLookup("[Enterprise ID]", "tbl_Roster", "[Enterprise ID]='" & strUsername & "'")
 
  Me.txtLName.Value = DLookup("[Last Name]", "tbl_Roster", "[Enterprise ID]='" & strUsername & "'")
    Me.txtFName.Value = DLookup("[First Name]", "tbl_Roster", "[Enterprise ID]='" & strUsername & "'")
 End Sub


Thanks for the help.:confused:
 
I am currently using this codes but doesnt works for me. Help me for easier use or any problem with my coding. Thanks.
Which part doesn't work? You are always saving the changes in the first record of the table, because you are opening the whole table with the recordset.
Code:
Set rst = db.OpenRecordset("tbl_Roster", dbOpenDynaset)
You need a "Where" clause for the [Enterprise ID].
I can't see if you've declared the db as DAO.Database and rst as DAO.Recordset, else you've to do it.
 
Which part doesn't work? You are always saving the changes in the first record of the table, because you are opening the whole table with the recordset.
Code:
Set rst = db.OpenRecordset("tbl_Roster", dbOpenDynaset)
You need a "Where" clause for the [Enterprise ID].
I can't see if you've declared the db as DAO.Database and rst as DAO.Recordset, else you've to do it.

How will I use the "WHERE" clause in my recordset? Like this?
Code:
Set rst = db.OpenRecordset("SELECT * FROM tbl_UsernamesQry WHERE [Enterprise ID] = '" & strUsername & "'", dbOpenDynaset)

Ive declared the db as DAO.Database and rst as DAO.Recordset in my GVar Modules, which is the Global Variables.
 
How will I use the "WHERE" clause in my recordset? Like this?
Code:
Set rst = db.OpenRecordset("SELECT * FROM tbl_UsernamesQry WHERE [Enterprise ID] = '" & strUsername & "'", dbOpenDynaset)
Ive declared the db as DAO.Database and rst as DAO.Recordset in my GVar Modules, which is the Global Variables.
Exactly, but with the table name "tbl_Roster" instead of "tbl_UsernamesQry".
 

Users who are viewing this thread

Back
Top Bottom