Displaying object based on specific record (1 Viewer)

kooheji

New member
Local time
Today, 21:58
Joined
Aug 12, 2014
Messages
6
Hello,
I am having bit of confusion in trying to come up with a code that will assist in completing my database display (for a warehouse rental database).

My aim is to have a form display a layout of the site and overlay an image over a store if its occupied else leave the image off if otherwise.

I have everything in my table plus a checkbox field that states if vacancy is "yes' or "no"; say I have 60 stores to rent and they have specific names (unit = A09) and I already 'drew' the layout on a form (all 60 of them) with renaming the boxes for each unit (Name = A09).

How can I program a code that upon opening the form it will like

If 'Box Name on form' = 'unit name on table' AND 'Vacancy = No' then 'redbox.visible = yes'


thank you.
 

JHB

Have been here a while
Local time
Today, 20:58
Joined
Jun 17, 2012
Messages
7,732
Use a recordset and a loop to cycle through the recordset result.
Recordsource for the recordset could be something like below.
SELECT [unit name] From YourTable Where Vacancy ='No';
 
Last edited:

kooheji

New member
Local time
Today, 21:58
Joined
Aug 12, 2014
Messages
6
Thank you for replying.

I forgot to mention that all 60 records must be on a single form to display the layout plan accordingly.

Earlier I tried to do it in one record with 60 fields; but this will fail when each unit requires to display its address, space, and tenant details.

Is there a work around to display them all records in one form.

Attached is how the form looks like, and each box suppose to be a record.
 

Attachments

  • warehouse_plan.jpg
    warehouse_plan.jpg
    44.3 KB · Views: 59

JHB

Have been here a while
Local time
Today, 20:58
Joined
Jun 17, 2012
Messages
7,732
I've made a small sample for you in the attached database.
I think it is much easier as a long explain how to do it.:)
 

Attachments

  • BoxForm.mdb
    308 KB · Views: 63
  • BoxForm.jpg
    BoxForm.jpg
    87.9 KB · Views: 172

kooheji

New member
Local time
Today, 21:58
Joined
Aug 12, 2014
Messages
6
Thank you very much,

I doubt I'd understand the code (even after going through all day yesterday what on earth recordset and how to loop it mean) but it works exactly how I need it to: many records on one single form.

Thank you again, I appreciate it.
 

JHB

Have been here a while
Local time
Today, 20:58
Joined
Jun 17, 2012
Messages
7,732
Thank you very much,

I doubt I'd understand the code (even after going through all day yesterday what on earth recordset and how to loop it mean) but it works exactly how I need it to: many records on one single form.

Thank you again, I appreciate it.
You're welcome.
Only for clarifying, "many records on one single form." is not the correct term, but you've many objects (boxes) on a form.

By the way, did you read my signature? :)
 

kooheji

New member
Local time
Today, 21:58
Joined
Aug 12, 2014
Messages
6
Does the code accommodate a combo box because I want to add another option (Vacant, Reserved, Occupied)?
 

JHB

Have been here a while
Local time
Today, 20:58
Joined
Jun 17, 2012
Messages
7,732
If you mean to add a combo box in the table structure, then no, not without changing the code.
 

kooheji

New member
Local time
Today, 21:58
Joined
Aug 12, 2014
Messages
6
If you mean to add a combo box in the table structure, then no, not without changing the code.

Alright? I mean can I use CASE for this or it still requires something else?

(I'm sorry, but I barely can keep up with vba)
 

JHB

Have been here a while
Local time
Today, 20:58
Joined
Jun 17, 2012
Messages
7,732
Try it now, database attached.
 

Attachments

  • BoxForm.zip
    18.9 KB · Views: 67

Users who are viewing this thread

Top Bottom