Hi..
how can i get the username who login in the form? I need to display it like the one above this form..
and can anybody give me an example of function how to use the insert into in database..this is my code how I insert the values.. - If rsmain.Supports(adAddNew) Then
-
With rsmain
-
.AddNew
-
.Fields("case_id") = case_id
-
.Fields("category") = cmbcat
-
.Fields("case_summary") = case_sum
-
.Fields("sub_case") = sub_case2
-
.Fields("priority") = cmbpriority
-
.Fields("start_date_time") = txtstart
-
.Fields("escalated_date_time") = txtescalated
-
.Fields("clear_date_time") = txtclear
-
.Fields("status") = txtstat
-
.Fields("tempstat") = frstatus
-
.Fields("escalated_to") = cmbescalatedto
-
.Fields("class") = cmbclass
-
.Fields("total_complaints") = txttotal
-
.Fields("case_source") = cmbsource
-
.Fields("prob_desc") = txtproblem
-
.Fields("worklog") = txtlog
-
.Fields("case_attach") = txtattach
-
.Fields("res_details") = details
-
.Fields("res_sum") = ressum
-
.Update
thanx in advance..
-cassey
8 2145
Hi..
how can i get the username who login in the form? I need to display it like the one above this form..
and can anybody give me an example of function how to use the insert into in database..this is my code how I insert the values..
If rsmain.Supports(adAddNew) Then
With rsmain
.AddNew
.Fields("case_id") = case_id
.Fields("category") = cmbcat
.Fields("case_summary") = case_sum
.Fields("sub_case") = sub_case2
.Fields("priority") = cmbpriority
.Fields("start_date_time") = txtstart
.Fields("escalated_date_time") = txtescalated
.Fields("clear_date_time") = txtclear
.Fields("status") = txtstat
.Fields("tempstat") = frstatus
.Fields("escalated_to") = cmbescalatedto
.Fields("class") = cmbclass
.Fields("total_complaints") = txttotal
.Fields("case_source") = cmbsource
.Fields("prob_desc") = txtproblem
.Fields("worklog") = txtlog
.Fields("case_attach") = txtattach
.Fields("res_details") = details
.Fields("res_sum") = ressum
.Update
thanx in advance..
-cassey
Hi cassey, would you please post the code for the login form? The code above makes no reference to the username
Hi cassey, would you please post the code for the login form? The code above makes no reference to the username
sure..but the code above refers to the insert query..i also need help in inserting a query in database..hope you give example too..
tanx..
heres the code for login: - Set RS = New adodb.Recordset
-
Set RS.ActiveConnection = CurrentProject.Connection
-
-
RS.Open "Select Count(*) as cnt from PASSWORD where initial = '" & Me![txtusername] & "' AND password = '" & Me![txtpassword] & "'"
-
If RS("cnt") = 0 Then
-
MsgBox "INVALID Username/Password. Please Try again!"
-
-
txtpassword = ""
-
Else
-
RS.Close
-
MsgBox ("You are now login")
-
'Forms!menu.Visible = True
-
DoCmd.OpenForm "mainmenu"
-
Forms!frmlogin.Visible = False
-
-
Exit Sub
-
End If
Hey, here is some code I recently used for a login button, the username attribute is actually never defined, it is simply searched for and if it is there then the password validation kicks in.
but you could define it by
Dim userName as String
...
userName = me.txtMemberName
(or from another form
username = Nz(Forms!frmLogin!txtMembername, ""
) -
-
Private Sub btnLogin_Click()
-
-
Dim un As String
-
Dim userType As String
-
Dim status As String
-
-
If IsNull(DLookup("userPassword", "tblUser", "UserID=" & Chr(34) & Me.txtMembername & Chr(34))) Then
-
-
' not found
-
-
MsgBox "Sorry, your username was not found, Please re-enter a valid username"
-
Exit Sub
-
-
Else
-
-
If DLookup("userPassword", "tblUser", "UserID=" & Chr(34) & Me.txtMembername & Chr(34)) <> Me.txtPassword Then
-
-
' wrong password
-
MsgBox "Sorry, your password does not match the username " &
-
-
DLookup("userPassword", "tblUser", "UserID=" _
-
& Chr(34) & Me.txtMembername & Chr(34)) & ", Please re-enter your password"
-
Exit Sub
-
-
Else
-
-
If status = "Inactive" Then
-
MsgBox "You are not currently signed into the AR System, please sign in before using JR"
-
-
Exit Sub
-
-
Else
-
' OK
-
-
userType = DLookup("userType", "tblUser", "UserID=" & Chr(34) & Me.txtMembername & Chr(34))
-
-
End If
-
End If
-
-
If userType = "Engineer" Then
-
DoCmd.OpenForm "frmEngMenu"
-
-
Else
-
DoCmd.OpenForm "frmForMenu"
-
-
End If
-
-
End If
-
-
PS - If you are having trouble with Update/Insert SQL etc check out my post http://www.thescripts.com/forum/thread586633.html
If you cant find the answer to your question there, there is a post on the bottom of the 2nd page linking to Access FAQs where your answr should be.
sure..but the code above refers to the insert query..i also need help in inserting a query in database..hope you give example too..
tanx..
heres the code for login: - Set RS = New adodb.Recordset
-
Set RS.ActiveConnection = CurrentProject.Connection
-
-
RS.Open "Select Count(*) as cnt from PASSWORD where initial = '" & Me![txtusername] & "' AND password = '" & Me![txtpassword] & "'"
-
If RS("cnt") = 0 Then
-
MsgBox "INVALID Username/Password. Please Try again!"
-
-
txtpassword = ""
-
Else
-
RS.Close
-
MsgBox ("You are now login")
-
'Forms!menu.Visible = True
-
DoCmd.OpenForm "mainmenu"
-
Forms!frmlogin.Visible = False
-
-
Exit Sub
-
End If
So you have the username stored here:
Forms!frmlogin![txtusername]
and you should be able to access it at anytime because it has not been closed. It is just not visible.
Hi..
how can i get the username who login in the form? I need to display it like the one above this form..
and can anybody give me an example of function how to use the insert into in database..this is my code how I insert the values.. - If rsmain.Supports(adAddNew) Then
-
With rsmain
-
.AddNew
-
.Fields("case_id") = case_id
-
.Fields("category") = cmbcat
-
.Fields("case_summary") = case_sum
-
.Fields("sub_case") = sub_case2
-
.Fields("priority") = cmbpriority
-
.Fields("start_date_time") = txtstart
-
.Fields("escalated_date_time") = txtescalated
-
.Fields("clear_date_time") = txtclear
-
.Fields("status") = txtstat
-
.Fields("tempstat") = frstatus
-
.Fields("escalated_to") = cmbescalatedto
-
.Fields("class") = cmbclass
-
.Fields("total_complaints") = txttotal
-
.Fields("case_source") = cmbsource
-
.Fields("prob_desc") = txtproblem
-
.Fields("worklog") = txtlog
-
.Fields("case_attach") = txtattach
-
.Fields("res_details") = details
-
.Fields("res_sum") = ressum
-
.Update
thanx in advance..
-cassey
In you are referring to the standard Access Dialog Log-In when Security is set on a Database, the Name of the Current User can be found by the CurrentUser() Method: - Debug.Print "The Current User of this Database is " & CurrentUser()
So you have the username stored here:
Forms!frmlogin![txtusername]
and you should be able to access it at anytime because it has not been closed. It is just not visible.
Indeed! That is a reference to the other open form, keeping forms maximised in the background will keep this variable usable. For a logout button all I have is a macro on the button that closes the menu, then the login form and then re-opens the login form, wiping the values, and thus logign the user out.
Hey, here is some code I recently used for a login button, the username attribute is actually never defined, it is simply searched for and if it is there then the password validation kicks in.
but you could define it by
Dim userName as String
...
userName = me.txtMemberName
(or from another form
username = Nz(Forms!frmLogin!txtMembername, ""
) -
-
Private Sub btnLogin_Click()
-
-
Dim un As String
-
Dim userType As String
-
Dim status As String
-
-
If IsNull(DLookup("userPassword", "tblUser", "UserID=" & Chr(34) & Me.txtMembername & Chr(34))) Then
-
-
' not found
-
-
MsgBox "Sorry, your username was not found, Please re-enter a valid username"
-
Exit Sub
-
-
Else
-
-
If DLookup("userPassword", "tblUser", "UserID=" & Chr(34) & Me.txtMembername & Chr(34)) <> Me.txtPassword Then
-
-
' wrong password
-
MsgBox "Sorry, your password does not match the username " &
-
-
DLookup("userPassword", "tblUser", "UserID=" _
-
& Chr(34) & Me.txtMembername & Chr(34)) & ", Please re-enter your password"
-
Exit Sub
-
-
Else
-
-
If status = "Inactive" Then
-
MsgBox "You are not currently signed into the AR System, please sign in before using JR"
-
-
Exit Sub
-
-
Else
-
' OK
-
-
userType = DLookup("userType", "tblUser", "UserID=" & Chr(34) & Me.txtMembername & Chr(34))
-
-
End If
-
End If
-
-
If userType = "Engineer" Then
-
DoCmd.OpenForm "frmEngMenu"
-
-
Else
-
DoCmd.OpenForm "frmForMenu"
-
-
End If
-
-
End If
-
-
PS - If you are having trouble with Update/Insert SQL etc check out my post http://www.thescripts.com/forum/thread586633.html
If you cant find the answer to your question there, there is a post on the bottom of the 2nd page linking to Access FAQs where your answr should be.
thanx for all the reply..but I need to display the user in the main form..how can i do that??
thanx for all the reply..but I need to display the user in the main form..how can i do that??
Either using some kind of AFTER UPDATE function on the textbox you could set another text box to come visible, read only and populate it with the value in the username box?
Or use a sub form and pass the value to it?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Alex |
last post by:
Hi all,
I'm writing a small web application which searches a database based on
a date field, and populates a datagrid control with the results. The
datagrid control has selection buttons added...
|
by: Erik |
last post by:
Why isn't my update method getting called?
Pasted below is an aspx from a 1.1 application I'm working on. It has
two textboxes and a button for inserting data into the database, and a
datagrid...
|
by: Jan |
last post by:
I'd like a maketable query listing ClientID, and E-mail from another
table. This is simple, BUT I'd only like to get only the part after @
in the E-mail.
How would this work in MS Access 2003?
|
by: M |
last post by:
If I have a query I am writing, I can use the top 10 function to bring
back the top 10 rows. That's all fine if all I want is 10 rows.
What if I have a grouped query, and I have 5 entities that...
|
by: phopman |
last post by:
Hello!
I am currently working on a project. And have been assigned to get up to speed quickly on php. And even though I love the language, it's not easy to get up to speed in like 2 seconds :-)
...
|
by: srusskinyon |
last post by:
I need some help getting unique records from our database! I work for
a small non-profit homeless shelter. We keep track of guest
information as well as what services we have offered for...
|
by: KDawg44 |
last post by:
Hi,
I have PHP function that adds a record to the database. The table has
an ID that is AUTO_INCREMENT. Is there anyway to get that ID back
when I do any kind of insert? That ID is a foreign...
|
by: happyse27 |
last post by:
Hi All,
I modified the user registration script, but not sure how to make it check for each variable in terms of preventing junk registration and invalid characters?
Two codes below :
a)...
|
by: happyse27 |
last post by:
Hi All,
In perl script(item b below) where we check if html registration form are filled in properly without blank with the necessary fields, how to prompt users that the field are incomplete...
|
by: srig |
last post by:
hi all,
i hav created a webpart for inserting a record in asp.net ,c# and deploy it in sharepoint.. my code is executing properly.. when i deploy it it asks for insert new record and wen i get the...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |