A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Displaying variable value in text box



 
 
Thread Tools Display Modes
  #1  
Old December 15th, 2006, 04:59 PM posted to microsoft.public.access.forms
Bongard
external usenet poster
 
Posts: 122
Default Displaying variable value in text box

Hi, I have a crosscheck in a form that when the wrong amount is entered
it cancels the update and displays a message box informing the user
that the amount they posted will bring the loan balance below zero.
However, I would like to take that loan balance amount and also display
it in the msgbox so that the user knows what the current balance is. I
am retrieving the loan balance with a dlookup to a crosstab query. Here
is my current code:

var1 = DLookup("[balance]", "qry_Transactions_Crosstab", "[Loan Number]
= " & Forms![frm_Transactions]![Loan Number])
If var1 + Forms![frm_Transactions]![Amount] 0 Then


MsgBox "The outbound transaction must not bring the loan balance below
0 it is currently at var1"


and of course the msgbox just reads var1, but does not display the
value that var1 just looked up in the above line of code.

Any ideas would be appreciated thanks for your help!

-Brian

  #2  
Old December 15th, 2006, 05:07 PM posted to microsoft.public.access.forms
fredg
external usenet poster
 
Posts: 4,386
Default Displaying variable value in text box

On 15 Dec 2006 08:59:10 -0800, Bongard wrote:

Hi, I have a crosscheck in a form that when the wrong amount is entered
it cancels the update and displays a message box informing the user
that the amount they posted will bring the loan balance below zero.
However, I would like to take that loan balance amount and also display
it in the msgbox so that the user knows what the current balance is. I
am retrieving the loan balance with a dlookup to a crosstab query. Here
is my current code:

var1 = DLookup("[balance]", "qry_Transactions_Crosstab", "[Loan Number]
= " & Forms![frm_Transactions]![Loan Number])
If var1 + Forms![frm_Transactions]![Amount] 0 Then

MsgBox "The outbound transaction must not bring the loan balance below
0 it is currently at var1"

and of course the msgbox just reads var1, but does not display the
value that var1 just looked up in the above line of code.

Any ideas would be appreciated thanks for your help!

-Brian


You need to concatenate the var1 data into the string, otherwise
Access thinks var1 is a literal part of the string.

MsgBox "The outbound transaction must not bring the loan balance
below 0 it is currently at " & var1
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
  #3  
Old December 15th, 2006, 05:39 PM posted to microsoft.public.access.forms
Klatuu
external usenet poster
 
Posts: 7,074
Default Displaying variable value in text box

fredg's answer is correct. You just has the syntax wrong.
Another thing you could do, if you would like the loan balance on the form
so the user could see it at any time would be to use the code you use to
populate the var1 variable as the Control Source of a text box on your form,
but without the var1 =

= DLookup("[balance]", "qry_Transactions_Crosstab", "[Loan Number] = " &
Forms![frm_Transactions]![Loan Number])

"Bongard" wrote:

Hi, I have a crosscheck in a form that when the wrong amount is entered
it cancels the update and displays a message box informing the user
that the amount they posted will bring the loan balance below zero.
However, I would like to take that loan balance amount and also display
it in the msgbox so that the user knows what the current balance is. I
am retrieving the loan balance with a dlookup to a crosstab query. Here
is my current code:

var1 = DLookup("[balance]", "qry_Transactions_Crosstab", "[Loan Number]
= " & Forms![frm_Transactions]![Loan Number])
If var1 + Forms![frm_Transactions]![Amount] 0 Then


MsgBox "The outbound transaction must not bring the loan balance below
0 it is currently at var1"


and of course the msgbox just reads var1, but does not display the
value that var1 just looked up in the above line of code.

Any ideas would be appreciated thanks for your help!

-Brian


  #4  
Old December 15th, 2006, 07:52 PM posted to microsoft.public.access.forms
Bongard
external usenet poster
 
Posts: 122
Default Displaying variable value in text box

Thank you very much guys, problem solved!


-brian

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:54 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.