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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA code to display multiple images in sinfgle Form 1

Status
Not open for further replies.

VBA2007

Technical User
Mar 24, 2012
16
0
0
US
Hello Everyone,
Can anyone please help me with the problem of displaying multiple images in a single form??

I want to display all the images in a "grid" or something like that. But unfortunately within a form its only displaying one record at a time. The image control is bounded to the image table.

If I make the form "continous form" then its showing one image in one row, where as I want to display images side-by-side.

Its really urgent, but I could not find any solution.

Any kind of help is really appreciated.

Thanks


 
I just made a small change in the code for the command button on click:

Code:
Private Sub cmdCalc_Click()

Forms!frmGrid1.Requery
CurrentDb.QueryDefs.Refresh
DoCmd.OpenQuery ("qryGrid1")

Now this is showing the ones that are selected instantly for the first time. In other words, working perfectly.

But from the same form if I select few more items and click on the command button then its opening the query view window but with the old results. If I press F5 then it refreshes the result with the current selections.

Is there any other way other than F5 through vba code that I could refresh the query??

 
Thanks MajP

Atlast, the query is executing perfectly. Along with the previous code I just added a small statement as suggested by MajP (I guess an expert in VBA)

Code:
Private Sub cmdCalc_Click()

Forms!frmGrid1.Requery
CurrentDb.QueryDefs.Refresh

DoCmd.OpenQuery ("qryGrid1")
DoCmd.Requery

End Sub

Things are looking good for now.

Could you suggest something about how to use the values from the above query for further calculation
like if imageID = 1 and selected = -1 then .....

Where imageID and Selected are the column names in the above query (qryGrid1)

Thanks
 
See Demo

If each food item has only one image then this is really not an image table but the image data should be fields in the "food item table". It is not really the image id but the "food item ID" that we are referencing. Just a little different paradigm. So I reorganized to reflect that. You would need a seperate image table if it was a 1 to many food items to images.

If you are capturing overall nutrition not just calories and PDA the table structure gets more complicated.

Assume for each food item you will capture
total fat
saturated fat
sodium
...

you would need a table
tblNutritionItem
nutritionItemID
nutritionItemDescription

example
1 Potassimum
2 Sodium
3 TransFat

then a table to form a many to many

tblFoodItem_NutritionItem
foodItemID_fk (relates to a food item)
nutritionID_fk (relates to the above nutritionItem)
PDA (PDA of that NI for that Food Item)

example
1 1 .20
1 2 .15

food item 1 has 20% PDA Potassium, 15% PDA sodium

Also lets say you want to create/save a meal and the related nutrition. You will need a meal table and again a many to many junction table for selected items.

tblMeal
mealID
mealDescription

tblMealItemsSelected
mealID_FK
foodItemID_fk


example
1 2
1 3
1 4

Meal one has foodItems (2,3,4)


Once you select your items you would run an insert query to save the Meal ID and all the fooditems to the above table.

You now can bring it all together and show
A complete meal of selections
The detail nutrition items for every selected item
The total calories and other summations for the meal.

Oh by the way I am an expert in VBA and Access, there is no guessing required.
 
For the demo, make your selections and hit the calculate button. Also these are demos of concepts, I am not suggesting you implement like that.
 
The demo link is not working. After the download when I am trying to open, its showing a message "unrecognized database format". Could you please re-send the link.

The whole thing sounds so complicated. Will try to take things one by one.

I am just a novice and not aware of how much we could achieve through Access. Moreover, I have a severe time constraint :(.

I am really greatful that an expert like you is helping me out. In a sense I am lucky that you saw my posting.

Thanks
 
See if this works.

When designing databases, the most important thing to do is to lay out the table structure so that it will support your needs and future needs. If that is done right then building user interfaces and reports become easy and adding utility becomes easy. A lot of times people will say "I need a database that has a form that does this..." which is the completely wrong way to start. This usually results in a database that can only do one thing and not really do that well.

So what I was saying is I do not know your general requirements, and I am guessing at a structure that may be required. This form should be just a small utility to support your overall data capture and data structure. It is not the cornerstone of the application.
 
BTW what is the urgency.
1) If you are a student please say so. I will still provide help, but tailor it differently, and provide more learning points.
2) If this is a club or non-profit that you volunteered for then I would be more motivated to help (assuming it is not the Aryan Nation or Al Qaeda or other non-desirable group who are concerned about their nutrition) I have put a lot of time on tek-tips for churches, schools, Kiwanis, Boy Scouts and other non-profits.
3) If you are a professional, I am not going to beat you up for biting off more than you can chew, because you probably know that already. Again my response would be crafted differently to explain what needs to be done/considered for a deliverable project.
 
Its again showing the same error. Is the demo file size 564KB ?? Everytime I am downloading a .accdb whose size is 564KB thats showing the "unrecognized format" error when trying to open.

I am a student but in some other stream. Have been asked to volunteer to design this for middle school kids just to guide them how to select food in fast food resturants. No funds so can't hire professionals. Don't have any other option. Have to do this anyhow.

Initially thought it would be easy just three screens: welcome, images and result. But when I started I realized I am in trouble. As I promised to do this, now I can't back off. I have to just make it presentable for the kids. Even if its a static one for the time-being its ok. Have to finish this fast so that I can concentrate on other stuff.

Inbetween I thought I should have switched to web-based software but again to learn them from scratch and prepare the whole thing would take too much time.

I know I should have started with a proper layout and design the data model but am not a professional. Just a self taught person.

I am thankful for this forum and obviously you. Now am feeling little hopeful.
 
I have been having some errors with the site, so let me try to download.
 
I downloaded from the site, and had no issue. I made a .mdb version.
see if that helps. I am on 2010 so maybe something is not readable.


Since it is a volunteer thing, I will try to help as much as I can. Probably will be off the net the rest of the day though. The more specific and the more descriptive you can be of additional capabilities the more I can help. Provide the big picture. Would not want to get you form working, and not have a way to tie it in to the other capabilities.
 
Thanks, Finally the download file is working. This seems perfect.

I don't want too many functionalities and you helped me to make a dynamic project that could even be modified or used in future. As I wrote earlier this is just for kids and I think this is more than enough. Will put it little more functionality and make the whole thing little flashy.

Thats it.

Done, YES:).

I know I could not thank you enough for your help. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top