Assuming you want to create a new record in an existing Access database table named “tbl_user” with fields “user_id”, “user_cat”, and “psw”, the following VBA code should do the trick:
Sub CreateUser() ' Open a connection to the Access database Dim db As DAO.Database Set db = CurrentDb() ' Create a new record in the tbl_user table Dim rs As DAO.Recordset Set rs = db.OpenRecordset("tbl_user", dbOpenDynaset) rs.AddNew ' Set the values of the new record rs("user_id").Value = "yourusername" rs("user_cat").Value = "admin" rs("psw").Value = "*******" 'replace *** with your password ' Save the new record and close the recordset and database rs.Update rs.Close db.Close End Sub
To use this code, open the VBA editor in Access by pressing Alt+F11, create a new module, and paste in the code. Then, simply run the CreateUser sub to create the new record. Note that you may need to update the code to match the specific field names and data types in your database.