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

Form Autofill - Can't see the wood for the tree's

Status
Not open for further replies.

campbellhatchard

Technical User
Mar 19, 2002
10
AU
I am creating a database to maintain stock volumes in a warehouse. In my Database I have a Table called Stock. Within this table I have two fields [OrderNo} which is a number field and is also the primary key and a second field called [StyleNo} which is a text field.

In one or the forms in which you enter despatch details I hace both these fields as entry fields. For ease of entry I have tried to set a "On Exit" event procedure set against the [OrderNo] field to autofill the [StyleNo] field.

The following is the event in VB

Private Sub Order_No_Exit(Cancel As Integer)
Dim varStyleNo As Variant
varStyleNo = DLookup("StyleNo", "Stock", "OrderNo = [OrderNo]")
If (Not IsNull(varStyleNo)) Then Me![StyleNo] = varStyleNo
End Sub

When the event is run I come up with the following error
Run-Time error '2465': Microsoft Access can't find the field 'StyleNo' referred to in your expression

When I go into debug, the exp. Me![StyleNo]=varStyleNo is highlighted in yellow.

I know I am probably looking straight at the problem but cant see the wood for the tree's.

Any assistance will be greatly appreciated. I am betting this will be the first of a few queries in relation to this project
 
OOpppsss, just got smacked in the head by that tree!!

I have figured it out. I broke the cardinal rule in my naming conventions. My field in the table is called StyleNo while my field in the form is called Style_No.

My apologies if I have wasted anyones time

For those interested, the correct coding shld read
Me![Style_No]=varStyleNo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top