Help needed with Database problems; Validation rule and Image in form (1 Viewer)

nicksargeant

New member
Local time
Today, 23:16
Joined
Apr 17, 2007
Messages
1
Hello Everyone,
I am in the final stages of creating a database for school coursework however I am having a few problems with a few features; any help would be much appreciated.
The database itself is meant to manage / keep are record of utility bills, it consists of two tables: Invoice and Company.

Problem 1.
In the Invoice table there are two fields called Date Due and Date Received the data type is Date/Time, how do I create a validation rule so that Date Due must be after 'Date Received' and vies versa?

Problem 2
I want each record in the database to store an image of a scanned invoice, and the main form called Transaction to show a preview image of the invoice. Much of the code I used is borrowed from the Access Northwind sample database, after some initial success I had to redesign the 'Transaction' form where the picture was shown and now I get the error message:
‘Run-time error 2135, this property is read-only and cannot be set’
I think I know what is causing the error but I have had no luck fixing it, if someone could help me that would be excellent.

Problem 3
Once I get the Transaction form to properly store and display a preview image of an invoice, I want to add a button that opens the image in an external window(ie MSPaint).
Currently my only success has been to add a button on the form that launches MSPaint (you have to manually open the image in MSPaint.)
Again, if someone could help me sort this out it would be excellent.

Sorry if my problems aren’t clear or well explained.

I have spent many hours looking for answers to my problems in forums, Access help files etc…
My computing tutor has little (no) experience with Access so he has been unable to help, hopefully the people on this forum have the expertise.

I am happy to email you my database if you need it to help me with problems 2&3.

Thanks in ALOT advance :)
-Sarge
 

Dennisk

AWF VIP
Local time
Today, 23:16
Joined
Jul 22, 2004
Messages
1,649
1) its best if you perform the validation on a form. use the before update event for both dates and insert your validation.

3) are you using the shell command if so you can extend the command line with the name of the image. or you could try the shellexecute with just the name of the image and windows will open the image according to the file type.

2) you don't specify enough info. here. use the debugger and single step through your code untill you find the line in error.

Hint: normally you would not want to store images in an Access db as it will bloat enormously. The usual tecnique is to use a text field to hold the path and name of the image.

ie mspaint.exe myimage.
 

RoyVidar

Registered User.
Local time
Tomorrow, 00:16
Joined
Sep 25, 2000
Messages
805
1 - data validation - get the table properties (not field properties), then in the validation rule enter

[Date Due]>[Date Received]

and some appropriate validation text

This will allow you to record only Date Due or only Date Received, but if both are present, Date Due will have to be "after" Date Received (btw - don't use spaces and special characters in object names, it'll come back and bite you ;) )

If you need both fields to have value, then change the Required property of the fields to Yes.

The difference between this and Dennisks suggestion, is that this will enforce this validation on the table at engine level. Now way you will be able to enter a record violating this. Form level "validation", only ensures you can't enter a record violating this from the form, so if you say import stuff from other databases, update through queries...

Many of us probably combine validations. Keep engine level validation to ensure there's no way to enter "bad" data, and use form level "validation" to provide more flexible and user friendly validation messages.

2 - if you search here (and other places), you will find more or less consensus of keeping the images on disk, and place a link/path to where they are stored in the db.
 

Users who are viewing this thread

Top Bottom