How to place two Images on one form ? (1 Viewer)

Adi44

New member
Local time
Today, 15:21
Joined
Apr 2, 2022
Messages
9
Good Afternoon All,

I have just joined this afternoon, primarily because I have been trying for several months to create a form with no luck.

I have a table which consists of :-
ID (Primary Key) <Autonumber>
Regn <Short Text>
Type <Short Text>
C/No <Short Text>
L/No <Short Text>
Operator <Short Text>
Image_Path <Short Text>

The form I wish to create would display these details for each record, two per row in a continious form ie two records per row, but still permit sorting on any of the fields, I have read numerous examples on the web of people trying to get multiple images on one row, but just cant seem to get mine to work ! I attach a screenshot of what I am trying to achieve. Any help would be very mych appreciated !!

Best Regards

Adrian
 

Attachments

  • Form example.PNG
    Form example.PNG
    214.3 KB · Views: 185

theDBguy

I’m here to help
Staff member
Local time
Today, 07:21
Joined
Oct 29, 2018
Messages
21,511
Hi. Welcome to AWF!

Not that's possible with a bound form. You might have to use an unbound for something like that. If you didn't need to update the data, you could use a report instead.
 

Adi44

New member
Local time
Today, 15:21
Joined
Apr 2, 2022
Messages
9
Hi. Welcome to AWF!

Not that's possible with a bound form. You might have to use an unbound for something like that. If you didn't need to update the data, you could use a report instead.
Hi DB Guy, thanks for the welcome !

so essentially I place two sub-forms on an un-bound master form ?

Many Thanks
 

theDBguy

I’m here to help
Staff member
Local time
Today, 07:21
Joined
Oct 29, 2018
Messages
21,511
Hi DB Guy, thanks for the welcome !

so essentially I place two sub-forms on an un-bound master form ?

Many Thanks
You could, or you could also setup a fixed amount of unbound controls to populate using code and just paginate to the next set of records.

Let's hope others may have better ideas.
 

GPGeorge

George Hepworth
Local time
Today, 07:21
Joined
Nov 25, 2004
Messages
1,944
I think the two subform approach would be the one I'd try to implement in preference to writing code ....
 

Adi44

New member
Local time
Today, 15:21
Joined
Apr 2, 2022
Messages
9
I think the two subform approach would be the one I'd try to implement in preference to writing code ....
Many Thanks for the reply, when i tried that access is saying that i cannot have a continious form (Ie the Master) with 2 sub-forms

Many Thanks
 

GPGeorge

George Hepworth
Local time
Today, 07:21
Joined
Nov 25, 2004
Messages
1,944
Many Thanks for the reply, when i tried that access is saying that i cannot have a continious form (Ie the Master) with 2 sub-forms

Many Thanks
If you can put them in the form's footer instead of the detail, you can get around that.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 15:21
Joined
Feb 19, 2013
Messages
16,641
you can do it if you can relate the records in some way so you can display both on one row. This example uses two non standard joins and assumes you are using a numeric PK. You will end up with fields from two records in the same row - in this example each field is designated as belonging to L or R tables.

SELECT L.*, R.*
FROM ((SELECT L.myTablePK AS leftRec, R.myTablePK AS rightRec
FROM

(SELECT A.myTablePK, Count(B.myTablePK) AS rownum
FROM myTable AS A INNER JOIN myTable AS B ON A.myTablePK>= B.myTablePK WHERE True GROUP BY A.myTablePK) AS L
LEFT JOIN
(SELECT A.myTablePK, Count(B.myTablePK) AS rownum
FROM myTable AS A INNER JOIN myTable AS B ON A.myTablePK>= B.myTablePK WHERE True GROUP BY A.myTablePK) AS R
ON L.rownum+1 = R.rownum
WHERE ((([L].[rownum] Mod 2)=1))) AS X
INNER JOIN myTable AS L ON X.leftRec = L.myTablePK) INNER JOIN myTable AS R ON X.rightRec = R.myTablePK;

the two parts in green are identical and use a non standard join to get a row number.

These are then joined with a non standard join to a) get the odd counted records as the left record PK and the even numbers as the right record PK (being the left count+1) - identified in blue. Note the left join in case there is not a final even number in the list

finally the left and right PK's are joined back to the original table in orange. Note the use of aliasing to keep it simple

This won't be an updateable query and clearly you will need to repeat controls for the left and right sides

all you should need to do is to change myTable to the name of your table and myTablePK to the name of your primary key.

with regards filtering you will need to apply criteria to both the green parts of the above query and not use the form filter functionality - replace True with whatever your filter requirements are - which is good practice anyway. I've included the WHERE True to hopefully make it easier to for you to edit, it is not actually required in this example

For sorting, you would need to change the join part A.myTablePK>= B.myTablePK in both the green sections to the field you are sorting on - i.e. to A.fieldName>=B.fieldName for ascending and B.fieldName>=A.fieldName for descending.
 

Adi44

New member
Local time
Today, 15:21
Joined
Apr 2, 2022
Messages
9
Good Morning CJ_London

That sounds exactly like what I was looking to achieve, many thanks for taking the trouble to explain, however I am new to access to so any form of coding is alien to me ! I attach a copy of my DB with table, form and sample queries, would it be possible for you to have a look at it for me and insert where the code needs to go ?

Many Thanks in advance

Adrian
 

Attachments

  • Database3.accdb
    1,004 KB · Views: 184
  • XV-NJA.jpg
    1.2 MB · Views: 149
  • XW-PKB.jpg
    1.2 MB · Views: 150

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 22:21
Joined
May 7, 2009
Messages
19,246
haven't downloaded any of your files yet (but might).
have you considered using webbrowser control.

 

CJ_London

Super Moderator
Staff member
Local time
Today, 15:21
Joined
Feb 19, 2013
Messages
16,641
There is no code to insert

I've modified the query for your table name and pk- and modified the form to show a couple of records, leave you to do the rest.
 

Attachments

  • Database3 (1).accdb
    1,004 KB · Views: 192

Adi44

New member
Local time
Today, 15:21
Joined
Apr 2, 2022
Messages
9
There is no code to insert

I've modified the query for your table name and pk- and modified the form to show a couple of records, leave you to do the rest.

Hi CJ London

That's brilliant, but when I try to make a search box, i create a text box to enter the search value, then create a command button that when pressed opens my form to display the value of the text box. unfortunately the command button wizard only allows one field to be matched, so the macro ends up being = = "[R.Regn] = " & "" & [Regn] & "", in other words it is only searchng the right table field, and not both. Also with sorting I can sort on only one field either L or R Regn....

Regards

Adrian
 

Adi44

New member
Local time
Today, 15:21
Joined
Apr 2, 2022
Messages
9
Hi ArnelGP

This is one of the examples I looked at and tried to modify, but i could not adjust the code to display just two images, and the path names were not generating images stored locally, I think i managed to get it to display the aircraft registration, type etc but that was about all

Regards

Adrian
 

CJ_London

Super Moderator
Staff member
Local time
Today, 15:21
Joined
Feb 19, 2013
Messages
16,641
Then pressed opens my form to display the value of the text box. unfortunately the command button wizard only allows one field to be matched, so the macro ends up being = = "[R.Regn] = " & "" & [Regn] & ""

See my post
with regards filtering you will need to apply criteria to both the green parts of the above query and not use the form filter functionality - replace True with whatever your filter requirements are - which is good practice anyway. I've included the WHERE True to hopefully make it easier to for you to edit, it is not actually required in this example

Also with sorting I can sort on only one field either L or R Regn....

Again, see my post

For sorting, you would need to change the join part A.myTablePK>= B.myTablePK in both the green sections to the field you are sorting on - i.e. to A.fieldName>=B.fieldName for ascending and B.fieldName>=A.fieldName for descending.
 

Adi44

New member
Local time
Today, 15:21
Joined
Apr 2, 2022
Messages
9
See my post
with regards filtering you will need to apply criteria to both the green parts of the above query and not use the form filter functionality - replace True with whatever your filter requirements are - which is good practice anyway. I've included the WHERE True to hopefully make it easier to for you to edit, it is not actually required in this example



Again, see my post

For sorting, you would need to change the join part A.myTablePK>= B.myTablePK in both the green sections to the field you are sorting on - i.e. to A.fieldName>=B.fieldName for ascending and B.fieldName>=A.fieldName for descending.
Good Morning CJ_London

I re-read your original post where you kindly posted the code for me, i am afraid that I would not have a clue how to do that, I can basically create tables, make a simple search and create forms and thats about it !!

I examined the sample DB you kindly posted, but could not even find which part to modify to allow a search or sort...

Regards

Adrian
 

CJ_London

Super Moderator
Staff member
Local time
Today, 15:21
Joined
Feb 19, 2013
Messages
16,641
If I do everything for you, you will never learn or understand how your app works. but suggest you will need to do the following:

1. Include the sql of the query as your form recordsource
2. I don't use macro's Assuming you are just trying to use the standard filter option of

me.filter="myfield ='" & mycontrol & "'"
me.filteron=true

then use the following (I'm assuming Regn is text)
me.recordsource=replace(me.recordsouce,"WHERE True","WHERE [Regn] = '" & [Regn] & "'")

if you are using the filter parameter of openform, move your filter parameter (i.,e. "[Regn] = '" & [Regn] & "'") to the openargs parameter instead and in the form open event put
me.recordsource=replace(me.recordsouce,"WHERE True",me.openargs)

3. for sorting - you will need a to use controls to to identify which field field you want to sort on and the direction (think how websites work)
and the code would then be something like

me.recordsource=replace(me.recordsouce,"A.myTablePK>= B.myTablePK","A." & ctlSortbyWhat & cltSortDirection & "B."& ctlSortbyWhat)

ctlSortdirection would probably be a combo using a value list to indicate ">=" is ascending and "<" is descending
 

Adi44

New member
Local time
Today, 15:21
Joined
Apr 2, 2022
Messages
9
I am really sorry CJ_London, but nthis is way beyond my understanding of access, where do i find the SQL of the query ? and where do i place the replacement code ? sorry, but i have no idea how to begin going about your reply. my knowledge of access is making a table and a form, and using the wizards, so how controls work etc is alien to me.

Regards

Adrian
 

Mike Krailo

Well-known member
Local time
Today, 10:21
Joined
Mar 28, 2020
Messages
1,044
Adi44, one of the most powerful things you can do with a database is query it for whatever information you want and display that information how you desire. Your request goes into an advanced query since access does not have any native way to do data grids like C# does. You have to crawl before you can walk, so start learning how to do some simple queries first. Check out the SQL view of all of your queries and try and see if any of it makes sense.
 

GPGeorge

George Hepworth
Local time
Today, 07:21
Joined
Nov 25, 2004
Messages
1,944
I am really sorry CJ_London, but nthis is way beyond my understanding of access, where do i find the SQL of the query ? and where do i place the replacement code ? sorry, but i have no idea how to begin going about your reply. my knowledge of access is making a table and a form, and using the wizards, so how controls work etc is alien to me.

Regards

Adrian
No time like the present to change that.

Learning is one of the most pleasant things we can do in life.

Since the focus in this discussion appears to be a query, start that learning with queries.

Besides, allowing others to take over and do your work for you cheats yourself out of any chance to experience the satisfaction of completing a job well done.
 

Users who are viewing this thread

Top Bottom