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 » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

If .....then ....



 
 
Thread Tools Display Modes
  #1  
Old July 3rd, 2008, 08:06 PM posted to microsoft.public.access
hyperkink[_2_]
external usenet poster
 
Posts: 9
Default If .....then ....

Hi: I have two text boxes, and one depends on the other. There are 3 optios,
when the score is 1, the ranking is 3. If the score is 2, and then the
ranking is 2. If score is 3, then the ranking is 1. I want to use VBA to
write some codes and achieve my goal, could you please help me do an example?
Thank you!
  #2  
Old July 3rd, 2008, 08:13 PM posted to microsoft.public.access
Ken Snell \(MVP\)
external usenet poster
 
Posts: 2,506
Default If .....then ....

If you just want to display the Ranking result in the one textbox based on
what the value is in the Score textbox, you could use this expression as the
ControlSource of the Ranking textbox (no VBA needed at all):

=Switch([ScoreControlName]=1,3,[ScoreControlName]=2,2,[ScoreControlName]=3,1)

If this is not what you want to do, please provide us more details and we
can suggest alternative approaches.
--

Ken Snell
MS ACCESS MVP


"hyperkink" wrote in message
...
Hi: I have two text boxes, and one depends on the other. There are 3
optios,
when the score is 1, the ranking is 3. If the score is 2, and then the
ranking is 2. If score is 3, then the ranking is 1. I want to use VBA to
write some codes and achieve my goal, could you please help me do an
example?
Thank you!



  #3  
Old July 3rd, 2008, 08:18 PM posted to microsoft.public.access
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default If .....then ....

Private Sub txtScore_AfterUpdate()

Select Case Me!txtScore
Case 1
Me!txtRanking = 3
Case 2
Me!txtRanking = 2
Case 3
Me!txtRanking = 1
End Select

End Sub

You may find, though, that it's better to have a table that relates the
score to the ranking so that you don't have to hard code them. In that case,
you could join the two tables in a query and use the query as the
RecordSource for your form. Changes to the Score would automatically update
the Ranking.


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"hyperkink" wrote in message
...
Hi: I have two text boxes, and one depends on the other. There are 3
optios,
when the score is 1, the ranking is 3. If the score is 2, and then the
ranking is 2. If score is 3, then the ranking is 1. I want to use VBA to
write some codes and achieve my goal, could you please help me do an
example?
Thank you!



  #4  
Old July 3rd, 2008, 08:23 PM posted to microsoft.public.access
Ryan
external usenet poster
 
Posts: 551
Default If .....then ....

Use the "AfterUpdate" event of Score to add this code
If Me!Score = 1 Then
Me!Ranking = 3
End If
If Me!Score = 2 Then
Me!Ranking = 2
End If
If Me!Score = 3 Then
Me!Ranking = 1
End If
End Sub

"hyperkink" wrote:

Hi: I have two text boxes, and one depends on the other. There are 3 optios,
when the score is 1, the ranking is 3. If the score is 2, and then the
ranking is 2. If score is 3, then the ranking is 1. I want to use VBA to
write some codes and achieve my goal, could you please help me do an example?
Thank you!

  #5  
Old July 3rd, 2008, 10:32 PM posted to microsoft.public.access
hyperkink[_2_]
external usenet poster
 
Posts: 9
Default If .....then ....

Hi: Thank you for your help. However, when I build codes for the Ranking text
box, nothings shows on the Ranking textbox. could you tell me why this
happens?

"Douglas J. Steele" wrote:

Private Sub txtScore_AfterUpdate()

Select Case Me!txtScore
Case 1
Me!txtRanking = 3
Case 2
Me!txtRanking = 2
Case 3
Me!txtRanking = 1
End Select

End Sub

You may find, though, that it's better to have a table that relates the
score to the ranking so that you don't have to hard code them. In that case,
you could join the two tables in a query and use the query as the
RecordSource for your form. Changes to the Score would automatically update
the Ranking.


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"hyperkink" wrote in message
...
Hi: I have two text boxes, and one depends on the other. There are 3
optios,
when the score is 1, the ranking is 3. If the score is 2, and then the
ranking is 2. If score is 3, then the ranking is 1. I want to use VBA to
write some codes and achieve my goal, could you please help me do an
example?
Thank you!




  #6  
Old July 3rd, 2008, 10:37 PM posted to microsoft.public.access
hyperkink[_2_]
external usenet poster
 
Posts: 9
Default If .....then ....

Thank you for your help. However, when i build codes for the Ranking textbox,
nothing show up. Could you please tell me why it happens?

"Douglas J. Steele" wrote:

Private Sub txtScore_AfterUpdate()

Select Case Me!txtScore
Case 1
Me!txtRanking = 3
Case 2
Me!txtRanking = 2
Case 3
Me!txtRanking = 1
End Select

End Sub

You may find, though, that it's better to have a table that relates the
score to the ranking so that you don't have to hard code them. In that case,
you could join the two tables in a query and use the query as the
RecordSource for your form. Changes to the Score would automatically update
the Ranking.


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"hyperkink" wrote in message
...
Hi: I have two text boxes, and one depends on the other. There are 3
optios,
when the score is 1, the ranking is 3. If the score is 2, and then the
ranking is 2. If score is 3, then the ranking is 1. I want to use VBA to
write some codes and achieve my goal, could you please help me do an
example?
Thank you!




  #7  
Old July 4th, 2008, 12:31 AM posted to microsoft.public.access
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default If .....then ....

Not sure what you mean by "build codes for the Ranking text box". Are you
talking about the code I suggested for the AfterUpdate event of the Score
text box, or are you talking about some other code? You do know that you
need to use the names of your text boxes where I've got txtScore and
txtRanking I hope!

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"hyperkink" wrote in message
...
Hi: Thank you for your help. However, when I build codes for the Ranking
text
box, nothings shows on the Ranking textbox. could you tell me why this
happens?

"Douglas J. Steele" wrote:

Private Sub txtScore_AfterUpdate()

Select Case Me!txtScore
Case 1
Me!txtRanking = 3
Case 2
Me!txtRanking = 2
Case 3
Me!txtRanking = 1
End Select

End Sub

You may find, though, that it's better to have a table that relates the
score to the ranking so that you don't have to hard code them. In that
case,
you could join the two tables in a query and use the query as the
RecordSource for your form. Changes to the Score would automatically
update
the Ranking.


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"hyperkink" wrote in message
...
Hi: I have two text boxes, and one depends on the other. There are 3
optios,
when the score is 1, the ranking is 3. If the score is 2, and then the
ranking is 2. If score is 3, then the ranking is 1. I want to use VBA
to
write some codes and achieve my goal, could you please help me do an
example?
Thank you!






  #8  
Old July 4th, 2008, 01:02 AM posted to microsoft.public.access
Larry Linson
external usenet poster
 
Posts: 3,112
Default If .....then ....


"hyperkink" wrote

Thank you for your help. However, when i build codes
for the Ranking textbox, nothing show up. Could you
please tell me why it happens?


Possibly, someone could assist you if your question was clear... "i build
codes for the Ranking textbox" does not really explain what you did, nor
where you put the code (I'm presuming that "i build codes" means that you
wrote or created VBA statements, known collectively as 'code' not 'codes',
and placed them somewhere anticipating that they would be executed). But
without knowing what and where, we'd only be guessing.

Larry Linson
Microsoft Office Access MVP


 




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 12:10 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.