473,395 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Can two image subforms use the same module?

22
I decided to try to add the picture feature to another form. So, I have two image subforms now, one for the kids pics and one for the adult pics. The kids one refers to the kids table, the adult to the adult table, etc.

But ever since i tried to create the one for the adults form, my db crashes. it seems to have suffered some serious corruption, and I had to spend some time piecing it back together... i don't know if it is a coincidence or not.

My question is can both of my image subforms use the same module? i am not at all experienced with code... i have found bits and pieces and used it, but i probably know enough to be really dangerous! Thanks again,
Oct 1 '11 #1
11 1631
NeoPa
32,556 Expert Mod 16PB
I suggest that really depends on your usage of the term subform.

A form can be used as a subform. The same form design (with a single associated module) can be used as two separate subforms within another form. In that sense it is possible.

If, on the other hand, you are referring to two separately defined forms which you want to act as subforms for a third, then in that sense it is not possible (as the module is directly associated with a form design).

If the latter is what you're after then you still have some scope to define much of your code in a standard module and the rest in the two separate forms such that the two forms call the standard module code to do most of their work.
Oct 1 '11 #2
CharT
22
Oh- i think i understand. would it help if i pasted the code? the subforms, called "imageA" and "imageC" (a is used in the adult main form and c is used in the child main form) are exactly the same, except for that the record source for a is the adult table and the record source for c is the child table.

I had found some code that i used from the internet that looks up the file path in a text field of a table and displays that image. I combined it with the code i was given yesterday (here) to add the browse feature. I was pleasantly surprised that i was able to meld the two pieces together. Here it is:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Public Function DisplayImage(ctlImageControl As Control, strImagePath As Variant) As String
  5. On Error GoTo Err_DisplayImage
  6.  
  7. Dim strResult As String
  8. Dim strDatabasePath As String
  9. Dim intSlashLocation As Integer
  10.  
  11. With ctlImageControl
  12.     If IsNull(strImagePath) Then
  13.         .Visible = False
  14.         strResult = "No image name specified."
  15.     Else
  16.         If InStr(1, strImagePath, "\") = 0 Then
  17.             ' Path is relative
  18.             strDatabasePath = CurrentProject.FullName
  19.             intSlashLocation = InStrRev(strDatabasePath, "\", Len(strDatabasePath))
  20.             strDatabasePath = Left(strDatabasePath, intSlashLocation)
  21.             strImagePath = strDatabasePath & strImagePath
  22.         End If
  23.         .Visible = True
  24.         .Picture = strImagePath
  25.         strResult = "Image found and displayed."
  26.     End If
  27. End With
  28.  
  29. Exit_DisplayImage:
  30.     DisplayImage = strResult
  31.     Exit Function
  32.  
  33. Err_DisplayImage:
  34.     Select Case Err.Number
  35.         Case 2220       ' Can't find the picture.
  36.             ctlImageControl.Visible = False
  37.             strResult = "Can't find image in the specified name."
  38.             Resume Exit_DisplayImage:
  39.         Case Else       ' Some other error.
  40.             MsgBox Err.Number & " " & Err.Description
  41.             strResult = "An error occurred displaying image."
  42.             Resume Exit_DisplayImage:
  43.     End Select
  44. End Function
Oct 1 '11 #3
NeoPa
32,556 Expert Mod 16PB
Not really :-S

I wasn't sure what you were trying to say so I answered both possible interpretations of the question. It wouldn't hurt to make the question clearer, but that's probably redundant now as I've answered both possible interpretations anyway.

I guess you haven't understood something of my answer(s). I suggest if you want help understanding that, you should explain where you're confused (It's hard to clear up confusion if you don't know where it is).
Oct 1 '11 #4
CharT
22
I'm so sorry... i completely agree, its difficult to clear up confusion if you don't know where it is! I feel like a blind man trying to describe what i am seeing :)

i think my use of the subforms fits your first scenario. (i think)... okay here i go again:

I have a main form called "adult info" this main form has in the detail section the fields from the underlying table as well as the image subform that displays the adult's picture.

I ALSO have a main form called "child info". This main form has lots of tabbed pages and lots of subforms... but, the in the detail section are the fields from the underlying child info table, and the (copy) of the image subform to display the child's image.

Both the images subforms are exactly the same, other than the record source. One displays pictures of child from the file path stored in the child info table, and the other displays pictures of the adults from the file path in the adult info table.

clear as mud?? :) (i am so very grateful for your help, as you can see i am not very good at this yet, but i aspire to be some day!)
Oct 1 '11 #5
NeoPa
32,556 Expert Mod 16PB
Subforms are complicated to explain, as general parlance describes both the form itself, and the control it's put in, as a subform. Whenever a subform is used on a main form there are three items that must exist :
  1. The main form itself. This will have a name and be found in your collection of forms in the database.
  2. A subform control on your main form. This is like a frame that the subform (#3 below) is displayed within. It is not a form as such.
  3. The sub form. This is also a form, has a name and is found in your collection of forms in the database. In fact, this can often be opened in its own right, though generally they are designed specifically for use within a subform control of another form.

You've described, and given names to, two main forms that each have a subform. What is/are the name(s) of these subform form(s)? If the answer to both is the same name, then the module for both is the same. If you have an Adult Subform, and a separate Child Subform, then they are not.
Oct 2 '11 #6
CharT
22
Thank you again for sticking with me on this! To answer your question, i have named my sub forms imagesa and imagesc. imagesa is on the main adults form, and imagesc is on the main children form.

So- two answer that question, yes, they have different names- but when i look at me list of modules, i have only 1, the module that i created when i made the first subform, imagesc.

when i copied imagesc and saved as imagesa so that i could add the picture feature to my adults form, it didn't make a module of its own, there is still only one. if i open both subforms (a and c) and look at the code in the code editor, they both have the exact same code.

Do I need to copy and past the code into another module so they each use their own code?

Thank you again,
Oct 2 '11 #7
NeoPa
32,556 Expert Mod 16PB
Can you confirm that when you talk about the objects ImagesA and ImagesC you are referring to form objects in the database and not control objects on forms. You don't seem to have picked up on the need for clarity of explanation made necessary by the ambiguity of the term in use. I know what I think you mean, but I'd rather deal with certainty at this stage, after having raised the point already in an earlier post.
Oct 2 '11 #8
CharT
22
i'm sorry, they are form objects. not control objects on forms.
Oct 2 '11 #9
NeoPa
32,556 Expert Mod 16PB
It's possible then, if your options are set that way, to have form and report objects without associated modules.

My first question for you to consider at this point would be - Is it necessary to have two separate forms for your images? If you can manage to use the same form as the subform for both main forms then that would make the most sense. If not, then ensure each has an associated module (For the one without, select a control and set one of the events of that control to "[Event Procedure]" from the Properties pane).

Once they both have modules available you can do what you will with them. To be honest I'm struggling to know what you're actually asking for. I hope I've answered the question, but if not just let me know, and what the question actually is, and I'll do what I can to help.
Oct 2 '11 #10
CharT
22
Yes, thank you that answers my question. I will implement your suggestions.
Oct 2 '11 #11
NeoPa
32,556 Expert Mod 16PB
Go for it - and good luck :-)
Oct 2 '11 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Steven Bethard | last post by:
I'd like to merge a module written in C with a module written in Python so that the user can access objects from either module by importing the single, merged module. Specifically, I'm looking...
6
by: Steve | last post by:
I have a form, primary subform and secondary subform. A tab control takes up all the area of the primary subform. There are about 15 tabs on the tabcontrol. Each tab contains fields from the same...
11
by: Lou Pecora | last post by:
From what I gleaned on some messages this is the way multiple imports of the same module work. Say, I have 3 modules (mod1.py, mod2.py, and mod3.py) and in the same session they all import another...
2
shane3341436
by: shane3341436 | last post by:
I want to make a page as in hi5.com in which I can keep hyperlink of an image, the image is then displayed on the same page as that of the hyperlink.
2
by: shogot99 | last post by:
Till here the info gotten is ok Loop Until strainfo = "" ScreenMNS.WaitHostQuiet (400) Second process Copy "B" & paste in "E" Range("B2:B600").Select
18
hsriat
by: hsriat | last post by:
Every time I right click on an image to open it in GIMP, its opens in a new GIMP instead of opening a new window in the already opened one. If I open 5 images, it will open 5 separate GIMPs. This...
11
by: nspader | last post by:
Hello all, Due to the size restriction of VBA code length I am forced to seperate my code accross Functions and call to them. The setup is simple I have a private function that runs...Within...
2
by: Robert Dailey | last post by:
Hi, I'm currently using boost::python::import() to import Python modules, so I'm not sure exactly which Python API function it is calling to import these files. I posted to the Boost.Python...
5
by: Nicole1307 | last post by:
Hi I'm trying to put together an Image Gallery. Everytime you click on an image it opens a new browser window. I want the Enlarged Imge to open in the same window in a designated area ('Box2'). How...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.