Link to home
Start Free TrialLog in
Avatar of muscats
muscats

asked on

Grid design for controls in form

I am trying to design a form where I have controls in a grid design 30 X 30 on a form, with all the controls unbound.  The idea is that users will be able to click on controls on the form and change the foreground and background colours with the aim of easily allowing users to graphically show where items are stored in a storage area.  I have created a details form with colour coding for each item selected by the user and can tranfer this information using code. However, I cannot workout how to store the info for each control and make the grid work short of making a separate table for each control in the grid and using subforms. Any ideas?
Avatar of simonbennett
simonbennett

Im not convinced I get this. Are you wanting to graphically represent data using text boxes, and store this?

From what you are saying you will have a 'grid' of 30 by 30 textboxes. When clicked upon, you want the colour(s) to change. You also want the user to be able to close the form, exit the app, and when the return to have the form in the same state?

Thanks

Simon
Whoops...

If so, then try this. Create a table like this called tblState

ID(int) ForeColour (long) Backcolour (long)
0       0                 256
1       8                 256
2       128               1024

Make your controls into a control array (called txtDisplay for eg) for ease of use. When opening the form, you can refer to each element in the array with the ID field in the new table. e.g.

with tblState
   Do while not .Eof
      Me.txtDisplay(![ID]).forecolor = ![Forecolor]
      Me.txtDisplay(![ID]).backcolor = ![backcolor]
      .movenext
   loop
end with

To save, when exiting the form just reverse the process like

For intLoopCount = 0 to 29

   set rstSave = currentdb.openrecordset("Select * From tblState Where ID = " & trim(str(intloopcount)),dbopendynaset)

   if rstsave.recordcount > 0 then

      rstsave.edit
      rstsave![ForeColor]=me.txtdisplay(intloopcount).forecolor
      rstsave![BackColor]=me.txtdisplay(intloopcount).backcolor
      rstsave.update

   end if

   rstsave.close

next intloopcount

HTH

Simon
If you have a stable design, you could try a solution like this:
create a user type to represent each of your button, and either make a table containing all your buttons data ( but take care of the limit on the nuimber of fields in a table) or better, make a master detail design with a table for the total store, and a table linked by a foreign key to the previous one, rerpesenting one button per record or a row of buttons (30) per record. Then you can choose to represent it as a single form with a query joining all the info, or as a master detail form...
ASKER CERTIFIED SOLUTION
Avatar of simonbennett
simonbennett

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial