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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|