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

Link Picture Img to main form problem

Status
Not open for further replies.

Kenny2003

Technical User
Dec 29, 2002
53
GB
Hi Guys,

I have a access 2003 database that I am creating for arciving plant details.

I have a bound object field that stores a jpeg imige of the plant and displays this when the appropiate record is selected in the database. (This all works just fine).

What I need to do now is to have a buton that when clicked, displays a larger or full size version of the picture but ONLY the picture for the selected record.

Here is the basic setup of my Database:

I have a main form (which displays the name of the database in a label box on the form header) and in the detail section, I have a hidden ID field and a tab control. The Tab contol has 3 pages, Page 1 displays the main data fields for the selected record, Page 2 is a memo field (called General notes) and page 3 is another memo field (called propigation notes).

On the tab control - Page 1, there is also another tab control that has two pages to display any images that are stored of the selected record. Page 1 is to show image 1 and page two is to display image 2 (that is if there are associated images stored).

Also on each of the pages is a button, that when clicked, opens a popup form which displays a full size version of the picture currently being shown in the 2nd tab page.
And this is where it goes wrong - if I click the button wlaying record 1 in the database it all works fine. Then if I navigate to record 2 in the database, the correct picture is displayed in the tab box bound field but if i then click on the button to display a larger image, it still displays the image for record 1 insted of the correct pic for what ever record number you are looking at. in short, I dont think the popup is refreshing or selecting the correct image.

I know this sounds all complicated and I hope that I have explained it as well as I could so any help or suggestion would be very gratefully accepted. If it would help, I can send you the database it's just over 3mb zipped.

Thanks for taking the time to read this post.

My thanks in advance,

Kenny
 
How are ya Kenny2003 . . . . .

Supply the following:
[ol][li]Form Name.[/li]
[li]The ID or PrimaryKey Name.[/li]
[li]The Names for the picutre objects, and corresponding button names. BTW, you can use the click event of the picture objects instead of the buttons. Let me know if this is perferred![/li][/ol]
I'll work up what ya need . . . . .

Calvin.gif
See Ya! . . . . . .
 
Hi earthandfire,

yeah the form is bound to the main table using a "autonumber" ID Field set as Primary Key.

Thanks for your reply and question.

Kenny
 
if I click the button wlaying record 1 in the database it all works fine
What is the actual code of the Click event procedure of this button ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi TheAceMAn1,

Thanks for the reply and here goes:

The main form (the one that contains all the other tab Ctrl's and sub form) is called frmPlant_Main

The sub form is called frmPlant_Sub

The ID/PrimaryKey is called ID_Field

The name of the picture objects are Image 1 (for pic 1) and
Image 2 (for pic 2).

I would prefer to have the larger image displayed using buttons if possible.

I hope this is the information you asked for and I appreciate your time and help in this matter.

Kenny
 
Hi PHV,

Thanks for your reply. Here is the code for the Click event procedure of the button to show a larger image.

Private Sub cmdLargeImage1_Click()
On Error GoTo Err_cmdLargeImage1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmImage1_Large"

stLinkCriteria = "[ID_Field]=" & Me![ID_Field]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdLargeImage1_Click:
Exit Sub

Err_cmdLargeImage1_Click:
MsgBox Err.Description
Resume Exit_cmdLargeImage1_Click

End Sub

Thanks again

Kenny
 
Try this:
DoCmd.OpenForm stDocName, , , stLinkCriteria, , acDialog

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
How are ya Kenny2003 . . . . .

I'm not sure what you have in the pop-up (zoom) form, but I'm gonna start from scratch (save the pop-up form).

[ol][li]Make a query that includes [purple]ID_Field[/purple], [purple]Image 1[/purple], [purple]Image 2[/purple]. In the criteria line for ID_Field copy/paste:
Code:
[blue]Forms!frmPlant_Main!ID_Field[/blue]
Save & name the query.[/li]
[li]Open the pop-up form in design view. [blue]Delete all the objects[/blue] (should only be the two picture objects) and [blue]any code in the code module[/blue].[/li]
[li]Set the [blue]RecordSource[/blue] of the pop-up to the [blue]query name[/blue] (you should be able to select it from the dropdown list).[/li]
[li]From the field list, drap/drop the [blue]1st image[/blue] control to the detail section and:
[ol a][li]Size the object to the maximum you desire ([purple]don't worry about the other Image[/purple]). Perform any positioning.[/li]
[li]Set the [blue]Visible[/blue] property to [purple]No[/purple].[/li]
[li]Set the [blue]Size Mode[/blue] to [purple]Zoom[/purple].[/li]
[li]Perform these same steps for the 2nd Image, putting it right on top the 1st Image![/li][/ol][/li]
[li]Save & close the pop-up.[li]
[li]Open [blue]frmPlant_Main[/blue] in design view.[/li]
[li]In the [blue]Click[/blue] event of the appropriate button, Copy/paste the following:
Code:
[blue][purple]Button for Image 1:[/purple]
   Call ZoomCtl(True)

[purple]Button for Image 2:[/purple]
   Call ZoomCtl(False)[/blue]
[/li]
[li]In the code module of [blue]frmPlant_Main[/blue], copy/paste the following (you substitute pop-up form name in [purple]purple[/purple]:
Code:
[blue]Private Sub ZoomCtl(Flg As Boolean)
   Dim frmName As String, ctl1 As Control, ctl2 As Control
   
   frmName = "[purple][b]PopupFormName[/b][/purple]"
   
   If IsOpenFrm(frmName) Then
      Forms(frmName).Requery
   Else
      DoCmd.OpenForm frmName
   End If
   
   Set ctl1 = Forms(frmName)![Image 1]
   Set ctl2 = Forms(frmName)![Image 2]
   
   If Flg Then
      ctl1.Visible = True
      ctl1.SetFocus
      ctl2.Visible = False
   Else
      ctl2.Visible = True
      ctl2.SetFocus
      ctl1.Visible = False
   End If
   
   Set ctl1 = Nothing
   Set ctl2 = Nothing
      
   
End Sub[/blue]
[/li]
[li]In a module in the modules window, copy/paste thefollowing code:
Code:
[blue]Function IsOpenFrm(frmName As String) As Boolean
   Dim cp As CurrentProject, Frms As Object
   
   Set cp = CurrentProject()
   Set Frms = cp.AllForms
   
   If Frms.Item(frmName).IsLoaded Then
      If Forms(frmName).CurrentView > 0 Then IsOpenFrm = True
   End If
   
   Set Frms = Nothing
   Set cp = Nothing

End Function[/blue]
[/li][/ol]
[purple]Thats it . . . give it a whirl & let me know . . .[/purple]

Calvin.gif
See Ya! . . . . . .
 
Hi Guys,

It Works!!!

Thanks for all the great advice and help and I have to say that while the solution suggested by TheAceMAn1 works just fine, the one from PHV is the most simple and also works just as well (for my needs.

All I have to do now is work out a way to automate insertion of JPEGS and I am sorted :)

Thanks again all,

Respect and thanks,

Kenny
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top