Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another combo box question

Status
Not open for further replies.

3587ch

Technical User
Jun 19, 2009
30
US
I have 5 rows of combo boxes, each row has 5 combo boxes and a button. When a user clicks a rows button I need all the values of the combo boxes in the rows below to move up one row.

I have it set this way now, but there must be a better way to program this?

This is the code in the first row button.

Me.cbotbl2 = Me.cbotbl3
Me.cbotbl3 = Me.cbotbl4
Me.cbotbl4 = Me.cbotbl5
Me.cbotbl5 = Me.cbotbl6
Me.cbotbl6 = Null

Me.cboJF1A = Me.cboJF2A
Me.cboJF2A = Me.cboJF3A
Me.cboJF3A = Me.cboJF4A
Me.cboJF4A = Me.cboJF5A
Me.cboJF5A = Null

Me.cboJtbl1 = Me.cboJtbl2
Me.cboJtbl2 = Me.cboJtbl3
Me.cboJtbl3 = Me.cboJtbl4
Me.cboJtbl4 = Me.cboJtbl5
Me.cboJtbl5 = Null

Me.cboJF1B = Me.cboJF2B
Me.cboJF2B = Me.cboJF3B
Me.cboJF3B = Me.cboJF4B
Me.cboJF4B = Me.cboJF5B
Me.cboJF5B = Null

Me.cboJoinType1 = Me.cboJoinType2
Me.cboJoinType2 = Me.cboJoinType3
Me.cboJoinType3 = Me.cboJoinType4
Me.cboJoinType4 = Me.cboJoinType5
Me.cboJoinType5 = Null
 
Quite an unusual specification. However, you could try something like
Code:
Dim intNum as Integer
For intNum = 1 to 5
  If intNum < 5 Then
   Me("cbotbl" & intNum + 1) = Me("cboTbl" & intNum + 2)
   Me("cboJF" & intNum & "A") = Me("cboJF" & intNum + 1 & "A")
   Me("cboJtbl" & intNum ) = Me("cboJtbl" & intNum + 1)
   Me("cboJF" & intNum & "B") = Me("cboJF" & intNum + 1 & "B")
   Me("cboJoinType" & intNum ) = Me("cboJoinType" & intNum + 1)
  Else
   Me("cbotbl" & intNum + 1) = Null
   Me("cboJF" & intNum & "A") = Null
   Me("cboJtbl" & intNum ) = Null
   Me("cboJF" & intNum & "B") = Null
   Me("cboJoinType" & intNum ) = Null
  End If
Next

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top