473,322 Members | 1,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Rectangle Coding Problem

First thanks in advance for any help... I am a newb when it comes to access, and am having trouble figuring out some... basic things... I think.

I am creating a DB that tracks our monthly Bills/Expenses etc... The form itself has an input section for creating new items and assigning to appropriate pay period, then there is a Listbox section where you can select and edit that information. The problem I am having, is that I created little rectangle boxes that will switch between green and red () on_Click to denote when Item is paid/not paid. I want to set it up so that depending which "rectangle" I click on, will change focus to the appropriate list box row, then change between checked/not checked respectively with the color. Now, the real problem is that I don't want the rectangles to appear when there is no data in the respective list box row. I thought I figured it out, but it does the opposite of what I want, it makes all the boxes dissappear for the ones that have data... Im confused. I really hope this makes sense to you pros out there. And appreciate any help in advance. Here is the code for making the "rectangles" dissappear if no data is the list box.

Expand|Select|Wrap|Line Numbers
  1. Private Sub BoxCheck()
  2. Dim intI As Integer
  3. Dim intC As Integer
  4.  
  5. C = Forms![BillExpUpdate].[lst1st_Bills].ListCount
  6. i = 0
  7. Do While i <> 17
  8.         If i < C Then
  9.         Forms![BillExpUpdate]("BoxPaid" & CStr(i)).BorderStyle = Solid
  10.         Forms![BillExpUpdate]("BoxPaid" & CStr(i)).BackStyle = Normal
  11.         Else
  12.         Forms![BillExpUpdate]("BoxPaid" & CStr(i)).BorderStyle = Transparent
  13.         Forms![BillExpUpdate]("BoxPaid" & CStr(i)).BackStyle = Transparent
  14. End If
  15. i = i + 1
  16. Loop
  17.  End Function
  18.  
Here is the code for selecting and changing the listbox color and toggling between paid/unpaid... I am still not sure how to create one piece of code that will apply to all 50 "rectangles" between the 4 list boxes... advice in this area would be great too. Thanks again.

Expand|Select|Wrap|Line Numbers
  1. Private Sub BoxCheck()
  2. Dim intI As Integer
  3.  
  4. 'Sets focus to 1st Bill List Box and selects line 0.
  5. Me.lst1st_Bills.SetFocus
  6. Me.lst1st_Bills.ListIndex = 0
  7.  
  8. 'If the 1st Bills "Paid" Box is Red, then will change to Green and set chkPaid value to "True"
  9. 'and refresh.
  10. If Me.BoxPaid0.BackColor = 255 Then
  11. Me.BoxPaid0.BackColor = 65280
  12. Me.chkPaid.SetFocus
  13. Me.chkPaid.Value = True
  14. Me.Refresh
  15. Else
  16.  
  17. 'If the 1st Bills "Paid" Box is Green, then will change to Red and set chkPaid value to "False"
  18. 'and refresh.
  19. Me.BoxPaid0.BackColor = 255
  20. Me.chkPaid.SetFocus
  21. Me.chkPaid.Value = False
  22. Me.Refresh
  23. End If
  24. End Sub
  25.  

[IMG]C:\Documents and Settings\Jeremy\Desktop\DBImage.bmp[/IMG]
Nov 12 '07 #1
2 1831
Ok, so I tried this way to... and it still changes ALL the boxes to transparent! What am I doing wrong here?

Expand|Select|Wrap|Line Numbers
  1. Public Function ScanBox()
  2. Dim intI As Integer
  3. Dim intC As Integer
  4. Forms![BillExpUpdate].[lst1st_Bills].Requery
  5. C = Forms![BillExpUpdate].[lst1st_Bills].ListCount
  6. i = 1
  7. Do While i <= 17
  8.         If i <= C Then GoTo Visible
  9.         If i > C Then GoTo InVisible
  10. Visible:
  11.         Forms![BillExpUpdate]("BoxPaid" & CStr(i)).BackStyle = Normal
  12.         Forms![BillExpUpdate]("BoxPaid" & CStr(i)).BorderStyle = Solid
  13.         GoTo Continue
  14. InVisible:
  15.         Forms![BillExpUpdate]("BoxPaid" & CStr(i)).BackStyle = Transparent
  16.         Forms![BillExpUpdate]("BoxPaid" & CStr(i)).BorderStyle = Transparent
  17.         GoTo Continue
  18. Continue:
  19. i = i + 1
  20. Loop
  21. End Function
  22.  
Nov 12 '07 #2
Alright... after bangin' my head against the monitor a few million times, here's what I found to actually work! :) Yeah! Let me know if there is a more efficient way to do this portion of the DB. Thanks.


Expand|Select|Wrap|Line Numbers
  1. Public Function ScanBox()
  2. Dim intI As Integer
  3. Dim intJ As Integer
  4. Dim intC1B As Integer
  5. Dim intC15B As Integer
  6.  
  7. '------------------------------------------------------------------
  8. 'Checks how many fields in each listbox have data.
  9.  
  10. C1B = Forms![BillExpUpdate].[lst1st_Bills].ListCount
  11. C15B = Forms![BillExpUpdate].[lst15th_Bills].ListCount
  12.  
  13. GoTo Visible
  14.  
  15. '------------------------------------------------------------------
  16. Visible:
  17. 'Sets ALL boxes visible
  18.  
  19. For i = 1 To 17
  20.         Forms![BillExpUpdate]("1stBoxPaid" & CStr(i)).Visible = True
  21.         Forms![BillExpUpdate]("1stBoxCleared" & CStr(i)).Visible = True
  22. Next
  23. For j = 1 To 17
  24.         Forms![BillExpUpdate]("15thBoxPaid" & CStr(j)).Visible = True
  25.         Forms![BillExpUpdate]("15thBoxCleared" & CStr(j)).Visible = True
  26. Next
  27. GoTo Invisible
  28.  
  29. '------------------------------------------------------------------
  30. Invisible:
  31. 'Sets UNBOUND boxes to Invisible
  32.  
  33. For i = C1B + 1 To 17
  34.         Forms![BillExpUpdate]("1stBoxPaid" & CStr(i)).Visible = False
  35.         Forms![BillExpUpdate]("1stBoxCleared" & CStr(i)).Visible = False
  36. Next
  37. For j = C15B + 1 To 17
  38.         Forms![BillExpUpdate]("15thBoxPaid" & CStr(j)).Visible = False
  39.         Forms![BillExpUpdate]("15thBoxCleared" & CStr(j)).Visible = False
  40. Next
  41.  
  42. '------------------------------------------------------------------
  43. End Function
  44.  
Nov 12 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Steven T. Hatton | last post by:
The following may strike many of you as just plain silly, but it represents the kind of delelima I find myself in when trying to make a design decision. This really is a toy project written for...
3
by: cjeffwang | last post by:
I am doing examples in "JavaScript: the Definitive Guide." For Example 8-1, a rectangle constructor function, how do I print/write the rectagle (x,y)? Here is the JavaScript program: ...
1
by: cider123 | last post by:
I've tried working with the SelectedIndices and Items.Selected attributes to get the problem to go away, but not having any luck. Questions I have are: 1) How do you move (using code) the...
15
by: Andrew McLellan | last post by:
I'm still finding my way round C# and am not sure what is possible and not possible. Is there any way to do the equivalent of Rectangle r = new Rectangle();...
3
by: | last post by:
I am having a hard time understanding the logic behind the Rectangle object. My problem has to do with the way the rectangle treats the "Width" property. For example, take the following rectangle...
4
by: nothix9 | last post by:
Hello guys, Ive been working this for 2 days, I am required to position a string using drawstring but the problem is its dynamic and changes depending on the database or source. A quick fix I thought...
4
by: RobinS | last post by:
I am drawing a rectangle on a picture that has already been drawn on the graphics area (a user control). It works something like this: //in the MouseDown event m_isDragging = true; m_oldX =...
2
by: John | last post by:
Hi there, I need to create a rectangle between two points so that I can check what is inside it using Contains(). The problem I am having is how to make the rectangle be able to cope with the...
2
by: joshguru | last post by:
i have to click a button and draw a rectangle in vb.net form like wise drawing a rectangle in painbrush..give me sample coding
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.