How to update the form fields to table thru a click button

sarohap

Registered User.
Local time
Today, 05:37
Joined
Nov 10, 2012
Messages
14
Hi all experts,

Please help out me in this case. I have 6 text box on the form which are unbound. Now we enter the entry in these boxes then I have update button on the form to update the record in table. all fields should be clear after update the records in table so I can enter the new entry.
I am using ms access 2007.
Is there any liberary to add?

Form fields

text1
text2
text3
text4
text5
text6

Table fields

emp_id
batchid
training_name
training_hour
start_date
end_date

Please help.......:banghead:


One more thing that which book is good to learn sql for the access and vba access book. please let me know the name....
 
Last edited:
Why not bind the text boxes to the underlying query?
You can then add a button to Add new record if you like.


Dale
 
I moved your thread to a more appropriate forum.
 
Hi Dale,
first i have bounded the fields. But when we user open the form then last record shows them which is do not want. fields should be blank when user login and get the entry form.


thanks paul to move this thread in appropriate forum...
 
Leave the Form Bound and this code will take you to a new, blank Record when the Form opens:
Code:
Private Sub Form_Load()
  DoCmd.GoToRecord , , acNewRec
 End Sub

Linq ;0)>
 
Last edited:
Thank you Linq....
now its working fine..
one more query that how to set the focus on first textbox after update the new record in table...
 
...how to set the focus on first textbox after update the new record in table...
Are you asking how to send the Focus to a given Textbox on a New Record? If so:
Code:
Private Sub Form_Current()
 Me.FirstTextboxName.SetFocus
End Sub
Just replace FirstTextboxName with the actual name of your Control/Textbox.

Linq ;0)>
 
Thank you so much linq..

My new query is..i have user table to login in the database..
this is user login table

userid = autonumber
emp_id = number
empname = text
username = text
password = memo
role = text.

this is admin userlogin table

adminID = autonumber
adminname = text
adminpassword = memo

if anyone login from admin then form should be open ("EntryandReportfrm")
if anyone login from usertable then form should be open ("entryfrm")
both are as example name can be different in below given code.


i m using the code here to login the users but it did not make any difference. so please help on this one also..

Public Sub Login()

On Error GoTo ErrorHandler:
If IsNull([cbouser]) = True Then 'Check UserName
MsgBox "Username is required"
cbouser.SetFocus

ElseIf IsNull([txtpassword]) = True Then 'Check Password
MsgBox "Password is required"
txtpassword.SetFocus

Else

'Compare value of txtPassword with the saved Password in tblUser
If Me.txtpassword.Value = DLookup("Password", "tblUsers", "[UserName]='" & Me.cbouser.Value & "'") Then
strUser = Me.cbouser.Value 'Set the value of strUser declared as Global Variable
strRole = DLookup("Role", "tblUsers", "[UserName]='" & Me.cbouser.Value & "'") 'set the value of strRole declared as Global Variable
DoCmd.Close acForm, "login_form", acSaveNo
MsgBox "Welcome, " & strUser, vbOKOnly, "Welcome"
DoCmd.OpenForm "Training_Form", acNormal, "", "", , acNormal

Else
MsgBox "Invalid Password. Please try again.", vbOKOnly, "Invalid Password"
intLogAttempt = intLogAttempt + 1
txtpassword.SetFocus

End If

End If

'Check if the user has 3 wrong log-in attempts and close the application
If intLogAttempt = 3 Then
MsgBox "You do not have access to this database.Please contact admin." & vbCrLf & vbCrLf & _
"Application will exit.", vbCritical, "Restricted Access!"
Application.Quit
End If
 
This is an entirely different question and needs to be moved to its own thread, along with an appropriate title.

Linq ;0)>
 
Oh thank you...so could you let me know that what is the title of that?
 
How to close the form after generate the report. Form has button to generate the report. when i click on the button then report pulls. but form do not close, So how it will be close after generate the report.
 
Same way you closed the login form in the code above. ;)
 
Hi Paul,
its not working which i have tired.. This is only one form with has only one button. so which code would close the form after getting the report.
 
Well, you haven't shown what you've tried, so I can only say the same type of code you used to close the login form:

DoCmd.Close acForm, "login_form", acSaveNo
 

Users who are viewing this thread

Back
Top Bottom