Comment log to record who post it

directx

New Member
Joined
Aug 2, 2017
Messages
13
Hello,

I'm newbie to all these "programming" excel and access things, so i needed some sort of database. I look at some tutorials, find some templates on internet and just edit it to fit my need's. I have the following problem:
I created Login Form
Code:

Code:
Option Compare DatabasePrivate Sub Command1_Click()
Dim User As String
Dim UserLevel As Integer
Dim TempPass As String
Dim ID As Integer
Dim UserName As String
Dim TempID As String




If IsNull(Me.txtUserName) Then
 MsgBox "Unesi Username", vbInformation, "Username neophodan"
 Me.txtUserName.SetFocus
ElseIf IsNull(Me.txtPassword) Then
 MsgBox "Unesi Password", vbInformation, "Password neophodan"
 Me.txtPassword.SetFocus
Else
 If (IsNull(DLookup("UserLogin", "tblUser", "UserLogin = '" & Me.txtUserName.Value & "' And UserPassword = '" & Me.txtPassword.Value & "'"))) Then
 MsgBox "Pogrešan Username ili Password"
 Else
 TempID = Me.txtUserName.Value
 UserName = DLookup("[UserName]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
 UserLevel = DLookup("[UserSecurity]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
 TempPass = DLookup("[UserPassword]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
 UserLogin = DLookup("[UserLogin]", "tblUser", "[UserLogin] = '" & Me.txtUserName.Value & "'")
 DoCmd.Close
 If (TempPass = "password") Then
 MsgBox "Please change Password", vbInformation, "New password required"
 DoCmd.OpenForm "frmUserinfo", , , "[UserLogin] = " & UserLogin
 Else
 'open different form according to user level
 If UserLevel = 1 Then ' for admin
 DoCmd.OpenForm "frmAdminPanel"
 Else
 DoCmd.OpenForm "UserForm"
 End If


 End If
 End If
End If
End Sub
I want to connect some entities and account so when some1 leave comment I can see who was logged at that moment.
At the moment it looks like this:
form.png


I also want to make few Value List's witch will be linked with comment in form:

Account name; Date; Time; 1st Value List; 2nd Value List; Comment
Code I'm using for comment history to link it with new comment:
Code:
=ColumnHistory([RecordSource];"Comments";"[ID]=" & Nz([ID];0))
I tryed with this code:
Code:
=ColumnHistory([RecordSource];"ValList1";"ValList2";"Comments";"[ID]=" & Nz([ID];0))
It was a failure

Maybe I havnt post enough information, if anything else is needed just say.
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Micron

Well-known Member
Joined
Jun 3, 2015
Messages
2,238
Office Version
  1. 365
Platform
  1. Windows
1) typical approach is to have a record for each authorized user in a table (tblUsers) which also contains their level, employee number, first name, last name (not together), etc. I would also have their network login id (not password). When they open the db, you run code to grab their network login id (Google fosUserName) and compare it (DLookup) to the table. Let them in if it passes, otherwise, no. Easier to then store the user name in a global/public variable (in a standard module) and refer to it whenever you need to. When trouble shooting your code, this value can often be lost, so I'd have a little procedure to reset it, otherwise you'd find yourself having to save work and restart the db. I'm saying you don't need the password form and its evaluation, but regardless you need the global variable and can lose its value regardless of which approach you take so create the procedure to reset it anyway. It's the global variable that allows you to capture who does what when they're working in the db. You can store the network login id, but you can lookup their number, FName, Lname, whatever you prefer to use.

2)What is recordsource, a field or table name? This is a reserved word and you should NOT use it for this:
Microsoft Access tips: Problem names and reserved words in Access
ColumnHistory looks like a procedure call and it seems you haven't posted it so it will not make sense to anyone reading your post. Not sure what you're asking for #2 ; how to make these lists, or how to link them.
If a record can have more than one comment associated with it, then you should have a table just for comments. You link the comment records to its parent table using the parent table's primary key. You'd link all the comment history to the asset/component, whatever it is related to. You don't link comment records to comment records:
Code I'm using for comment history to link it with new comment
 
Last edited:

Forum statistics

Threads
1,141,413
Messages
5,706,300
Members
421,440
Latest member
cmphares

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top