capturing/storing variables

L

lez

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
 
F

fredg

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.
 
L

lez

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 said:
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.
 
J

John Spencer MVP

I'm not sure what you are doing, but it sounds to me as if you need to add a
sub-report to your reports.

I build a repport that has just the company information in it laid out like a
letterhead. Then I use this report as a sub-report and include it in reports
that need this company information as a header. You can put the sub-report in
the Report's Header, or the Page Header, or a group header, etc.

Just one technique you might think about.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
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 said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top