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

Initiating event problem

Status
Not open for further replies.

atmospherik

Technical User
Feb 27, 2003
46
GB
I have a form which displays a product image if the 'stockcode.jpg' exists in a particular folder.

The stockcode is a 'manually coded' sequential number - this is currently generated (getting the next in the sequence from another table) when the BeforeInsert event fires - therefore only *new* records get the stockcode generated. The default value is -1 before it's generated.

Currently the script to check if the image exists (and display it) is fired from the onCurrent event.

My problem is this -

when the user adds a new record the stock code shows -1 initially. The image isn't displayed until moving away from the record and coming back to it. I'd like to fire the display image onCurrent aswell but it needs to be done *after* generating the stockcode.

If I want to generate the stockcode onCurrent so that the image can be immediately displayed then I need to check if the stockcode has been generated already. When I check it, it doesnt hold value -1 (I assume this is because the record hasn't been saved at this point) it seems to hold nothing (or is undefined??) so I can't see if I need to generate a stockcode...!

Phew.

If anyone can understand my ramblings above then i'd be very grateful for any advice. As you might tell i'm no Access or VB expert!

Paul
 
Just solved it.. always the way - having to explain it has made me realise i'm being stupid - all i had to check was the opposite - instead of seeing if stockcode = -1 or if stockcode = "" all I had to do was see if stockcode >0 and put the code to generate the stockcode in the else section.

like this...

Private Sub Form_Current()

If stockcode > 0 Then
MsgBox ("stockcode exists")
Else
MsgBox ("stockcode doesnt exist - so generate it")
stockcode = NewStockcode()
End If
On Error Resume Next

If image exists then display it etc...

End Sub



If anyone has been thinking about it thanks anyway!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top