View Single Post
  #3  
Old July 8th, 2009, 03:58 PM posted to microsoft.public.access
lez
external usenet poster
 
Posts: 27
Default capturing/storing variables

Hi Fred,

Sorry for that, let me provide a bit more detail.

Rather than add the items as a Dlookup or add a table to the query forthe
report, I just want to store the variables, name address, tel etc during the
session and apply them to any part of the application I need it.

I alreally capture the user details via a login method and use that to mark
records with the user adding/modifying the data.

I assume I could just add the additional values to the login process, but
was looking to see if there were any better sudggestions out their.

The database is setup with a Access 2007 FE and SQLEXPRESS 2005 BE, so need
to keep the performance at it's best.

my login code is

Private Sub cmdLogin_Click()
On Error GoTo Err_cmdLogin_Click

Dim AttemptsCounter As Integer
Dim myMsg As String

AttemptsCounter = Me.CheckAttempts.Value

If Me.txtPassword = Me.cboUser.Column(2) Then
UsrName = Me.cboUser.Column(1)
UsrPass = Me.cboUser.Column(2)
UsrUserID = Me.cboUser.Column(3)
UsrFullName = Me.cboUser.Column(4)
DoCmd.Close acForm, "frmLogin"
DoCmd.OpenForm "frmMainMenu", acNormal

Else
myMsg = "Incorrect password has been entered. Please try again."
Select Case AttemptsCounter
Case 1
myMsg = myMsg & vbNewLine & "Two attempts left before automatic
closing."
Me.CheckAttempts.Value = 2
Case 2
myMsg = myMsg & vbNewLine & "One attempt left before automatic
closing."
Me.CheckAttempts.Value = 3
Case 3
Beep
MsgBox "Unauthorized access.", vbCritical, "Invalid user."
Quit
End Select

Beep
MsgBox myMsg, vbCritical, "Incorrect Password."
Me.txtPassword.SetFocus
Me.txtPassword = Null
End
End If

Exit_cmdLogin_Click:
Exit Sub

Many thanks
Lez

"fredg" wrote in message
...
On Wed, 8 Jul 2009 15:12:40 +0100, lez wrote:

Hi Guys,

Can anyone tell me the best way to load and store variables to call when
users are in my application. In particular, I have a number of
reports/invoices etc that are produced.

I have a table that the user adds comapny details, name, address etc that
I
want to just load when a report/invoice is produced.

Many thanks


Your question is not very clear to me.
I'll guess you have information in a record in your table which you
wish to display on a report.

Add an unbound control to the report.
Set it's ControlSource to:
=DLookUp("[CompanyName]","TableName","[CompanyID] = " &
Me.[CompanyID])

Add another unbound control:
=DLookUp("[CompanyAddress]","TableName","[CompanyID] = " &
Me.[CompanyID])

etc.. for each additional field you need to include in the report.

[CompanyID] is the field in the report that identifies the Company.
The above code assumes [CompanyID] is a Number datatype.
If the actual datatype is Text, then use:
"[CompanyID] = """ & Me.[CompanyID] & """")

Of course you could always join this table to the other table(s) using
a query, and use that query as the report's record source.

If this isn't what you are looking for, please post back, clarifying
your question. Remember, we cannot see your database nor read your
mind.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail