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,
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.
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: - Option Compare Database
-
Option Explicit
-
-
Public Function DisplayImage(ctlImageControl As Control, strImagePath As Variant) As String
-
On Error GoTo Err_DisplayImage
-
-
Dim strResult As String
-
Dim strDatabasePath As String
-
Dim intSlashLocation As Integer
-
-
With ctlImageControl
-
If IsNull(strImagePath) Then
-
.Visible = False
-
strResult = "No image name specified."
-
Else
-
If InStr(1, strImagePath, "\") = 0 Then
-
' Path is relative
-
strDatabasePath = CurrentProject.FullName
-
intSlashLocation = InStrRev(strDatabasePath, "\", Len(strDatabasePath))
-
strDatabasePath = Left(strDatabasePath, intSlashLocation)
-
strImagePath = strDatabasePath & strImagePath
-
End If
-
.Visible = True
-
.Picture = strImagePath
-
strResult = "Image found and displayed."
-
End If
-
End With
-
-
Exit_DisplayImage:
-
DisplayImage = strResult
-
Exit Function
-
-
Err_DisplayImage:
-
Select Case Err.Number
-
Case 2220 ' Can't find the picture.
-
ctlImageControl.Visible = False
-
strResult = "Can't find image in the specified name."
-
Resume Exit_DisplayImage:
-
Case Else ' Some other error.
-
MsgBox Err.Number & " " & Err.Description
-
strResult = "An error occurred displaying image."
-
Resume Exit_DisplayImage:
-
End Select
-
End Function
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).
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!)
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 : - The main form itself. This will have a name and be found in your collection of forms in the database.
- 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.
- 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.
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,
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.
i'm sorry, they are form objects. not control objects on forms.
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.
Yes, thank you that answers my question. I will implement your suggestions.
NeoPa 32,556
Expert Mod 16PB
Go for it - and good luck :-)
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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.
|
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
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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,...
|
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...
| |