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!

How can I use Certificates I scanned and assign them to truck numbers? 2

Status
Not open for further replies.

testkitt2

Technical User
Apr 28, 2004
193
0
0
US
hello everyone.

I have a DB that maintains truck information...such as plate numbers, titles, inspections, so on and so forth.
These trucks have a certificate for the amount of weight
they can carry. I took all the physical cert's and scanned them. What I want to do is to add these cert's into the DB either as a "report" or a "form" (what ever is best) and assign a truck number to each cert, but the way I want it to work is by way of "stLinkCriteria" when you search for a truck on the main form you can then double click inside of the truck numbers "textbox" and link the cert with the current truck number showing. I want to use something like this to link to the cert (and bring up a popup)

Code:
stLinkCriteria = "[truckNumber]=" & "'" & Me![TruckNO] & "'"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
How do I add 41 certificates to my DB and how to assign a truck number to each cert. The cert are truck number specific, so the right truck number has to appear on the right cert.
_________________
FYI
current table, form names
mainform name "Unitplus"
table for main form name "tblUnitPlus"
truck textbox name (on mainform) name "TruckNo"

Does anyone have a suggestion...I appreciate any help at all

Thank you
JZ


Testkitt2
 
Let's stick to double-click for now, ok?
First (and I should have mentioned this earlier), make sure that the cert opens in some program when you double-click it, that is, that jpgs are associated with a program.

Next, paste the code below into your form and set the double-click for truckno to [Event Procedure] in the normal way.

You seem to give two names for the directory that holds the pictures:
1. OverWeights Pics
2. OverWeights
I think I will guess that the directory is called Overweights.
Code:
Private Sub TruckNo_DblClick(Cancel As Integer)
    Dim strPath, strFileName, strExtension

    'strPath needs to be on one line
    strPath = "C:\Documents and Settings\Testkitt2\Desktop\OverWeights\"
    strFileName = Trim(CStr(Me.TruckNo))
    strExtension = ".jpg"
    MsgBox strPath & strFileName & strExtension
    FollowHyperlink strPath & strFileName & strExtension
End Sub
I have included a message box for the directory, so you can check that it looks right, that it is picking up the truck name and so on. You can, of course, comment it out when we get this working.
 

Thanks Remou
I have to say...the code you suggested worked like a charm.
After using the search truck number command button, I double click inside the truckNo textbox and I get a small window showing the path and name of the cert..after clicking OK..Up pops the cert... I have Irfanview (Pic editor freeware) as my default prgm for JPG's. I could then view or print the certificates.
Thank you very much for your time and efforts and to all who contributed.

have a good one..
This thread is complete.
JZ

Testkitt2
 
Good eve to all..
Remou, Zion7

Sorry to reopen this thread.. but listen to this..I copied
the DB to my portable drive and took it to work copied the DB to the desktop, folder with the jpg certs and went to work. when I click on the textbox named "TruckNo" to bring up a cert..it works and it doesn't work.. when it doesn't work I get this msg..

Code:
Private Sub TruckNo_Click()
Dim strPath, strFileName, strExtension

    'strPath needs to be on one line
    strPath = "C:\Documents and Settings\Testkitt2\Desktop\OverWeights Pics\"
    strFileName = Trim(CStr(Me.TruckNo))
    strExtension = ".jpg"
    MsgBox strPath & strFileName & strExtension
    FollowHyperlink strPath & strFileName & strExtension
End Sub

To debug this line of code
Code:
[b]FollowHyperlink strPath & strFileName & strExtension[/b]

What is going on..
sorry to be a pain
Thank you'
JZ

Testkitt2
 
What is in the message box when it does not work?
 
remou

run-time error '490'

cannot open the specified file.

Thank you
JZ

Testkitt2
 
Have you checked what happens when you double-click on the file (jpg) itself? I suspect that there may be a problem with the file.
 
Hello Remou,

Thanks....When I double click on each file seperately in the folder, it opens with no problems. I've even tried to assign different programs to open the file with..by selecting "open with" and checking off the box that says "always open with this prgm"
Conclusion: each of the pics open...Now...within the DB I get the error.
Is there any other way of doing this. I know that creating 42 or more "reports" or "forms" will fatten up the DB. But like I said before I already have something similiar.. An Ins Card setup as a report with a textbox located on it. Its source is a query with a [enter a truck no] criteria. So that when you click on the command button (Main Form) and enter a truck no.. the Ins Card will print with the truck number you type in the textbox.
It's funny...I have Office 2003 at home and at my job they're running Office 2000. The original setup of the DB was done at my job... but most of the updates and modifications I do at home. It worked at first at home and then I tried it at my job and I got the error. That night I tried it at my house and it was it or miss...now all I get is the error.
Sorry for explaining too much...I just need help in resolving this.

Thanks for your efforts.
JZ

Testkitt2
 
It's a shame FollowHyperlink isn't working?
And yes, there are probably several other ways, to open a file. ie; CreateObject(), Shell()

JZ, what would creating 42 forms/reports do?
You said you have something similiar, a report with a parameter query, that prints what, just the truckNº?
Excuse me for being somewhat tenacious about this point, but for simplicity, i'd use an image control on the report, in design view(VBA), put its path in the Picture property, after you click, from the main form.

 

Thanks Zion7
To clarify a bit..when I say I have something similiar I meant this:

All the trucks are insured by the same co...thus for a corp..they sometimes issue a "for all owned vehicles" ins card..which will cover any truck...so all I had to do was scan one ins card and put it into a report format..the textbox thing is just frosting on the cake... when the command button is executed..it triggers the query that asks for the truck no... and all it does is put that truck no in the textbox located at the top of the ins card..nothing more.

now with the cert...they are truck specific and each cert has the trucks Vin#, plate#, weight...so on an so forth.
So in this case I would have to scan about forty somehting pics
Thanks
JZ


Testkitt2
 
Hello to all
Just to add a bit,,which I already have ...is the pics are already scanned and saved in two formats .bmp and .jpg..so the scanning part is already done...but like Remou stated on Feb 4ths post not to bloat the DB..instead using a hyperlink would be the best route.
At This point if it works...I wouldn't mind.

Thanks
JZ

Testkitt2
 
I get it!

yes, but simply having one report, and just changing the picture property at will, will keep the dBase leen.

Not sure if this is an option, as far as you are concerned.
Is there room on the report for the Cert image?

Either way JZ, give it a shot, I believe it is at least one, viable solution.

PS; I have an identical procedure going on over here.
About 60 scanned btm images. I originally tried using the Bound OLE Object, but MS, is having chronic problems with this, and has stopped all development (Northwind uses that technique, for employee photos. Changes image with each record)
 
Remou , Zion7
In going back and forth and trying all your suggs..
which were all good, The question "Why did the code not work at my job?" just kept bugging me. I think the answer was staring me right in the face. This DB and all other DB's I have running at the job are all split DB's where the BE lives on a network drive and all the users have a shortcut to the FE on their desktops. Now if the folder with the hyperlink to the Cert's(JPG's)is on the desktop I use at the job, is where the problem starts because it could not find the path or the network security did not allow it...right?. I could move the folder to the network drive and change the path.. or I can share the folder on my desktop so that the path could work. What do you guys think?

Testkitt2
 
I would be inclined to go with the network drive if this is a generally used set of certs.
 
Remou, Zion7

Thanks for your input.. I guess without any choice of my own I was kindof forced to use the following method:
Note: This new method as far as response time works great...just wondering on how it would differ from the hyperlink method suggested previously.

Anywaz this is what I ended up with:
Code:
a table I created... called tblImage
properties are:
ImageID         AutoNumber
txtImageName    Text
********************************************
a folder created to hold the images named: OverWgt ( on the C Drive )
********************************************
A funtioned called:  DImage
[code]
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
A Report named: RptImage
Source for the report "RptImage" is the "tblImage"
An image frame created on the report and linked to the path where the pictures are stored. C:\OverWgt\Sample.jpg
This method seems to be working...note: I will be scanning all the trucks registrations and the trucks "MVT stickers" (which go on the windshield)
I will create 2 new folders on the C drive
First C:\MVTS
second C:\Registrations
This will be all the scanning for this DB...Can you guys tell me..besides the time to scan and prepare the other documents..will this slow down the DB or make it any bulkier?
Thanks again guys
JZ



Testkitt2
 
JZ, as far as "I" know, No!, they're not even part of the DB. The slowness would only come from retrieving the file each time, which, I was just about to ask, how do you call the function?
I guess, you have the TruckNo, field on the report, which corresponds with the file name, which is the, 2nd argument.

So just changing pages/records, sinks the function each time? Clever!

I have mine, (similiar function), on the OnCurrent event.
I may reconsider(not as straightforward).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top