Runtime error

J

Joan

Hi,
I have a form called "SalesScreen" where on the AfterUpdate event of the
[Store] control I have the following code:

Private Sub Store_AfterUpdate()
Dim db As Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("EnterStoresQuery", dbOpenDynaset)
If Forms!SalesScreen!Returned = "Y" And Forms!SalesScreen![Store] Is Not
Null Then
Forms!SalesScreen!ReturnedStore = Forms!SalesScreen!Store
Forms!SalesScreen!ReturnedSalePrice = Forms!SalesScreen!SalesPrice
End If
rs.Close
db.Close

End Sub

When I update the [Store] field and press tab, I get the followin runtime
error: "Object required". What object am I missing?

This form (displays inventory of dogs) is used by salesmen to record the
storecode in the [Store] field of a dog record when they sell a dog to a
store. Sometimes dogs are returned from stores for one reason or another,
put back into inventory and resold. When a dog is returned, the dog record
again appears on the SalesScreen with the [Store] control blank so that the
saleman can enter the storecode again when the dog is resold. Behind the
scenes, unbeknown to the salesmen, fields need to be updated such as:
ReturnedStore(store the dog is sold to the second time) and
ReturnedSalesPrice (Price the dog is sold at the second time around). These
controls are on the SalesScreen form but are invisible to the user. This
essentially is what I am trying to do with the above code. What am I doing
wrong? Any suggestions are appreciated.

Joan
 
W

William Taylor

try this instead:
If Forms!SalesScreen!Returned = "Y" And Not
IsNull(Forms!SalesScreen![Store]) Then
 
J

Joan

William,
Thanks for your reply.

I tried using the expression you suggested instead and it puts the value in
the [Store] control in the [ReturnedStore] control after Store is updated.
It also puts the SalesPrice amount in the ReturnedSalePrice control after
updating like I wanted. However, if the user made a mistake and wanted to
take out the value in Store by backspacing or deleting, the value does not
also come out of [ReturnedStore] . Likewise with [SalesPrice] and
[ReturnedSalePrice]. Now if they put in a new value, that will show up in
the Returned* fields but not if they just want it to be blank after
mistakenly putting a value in the wrong record. What do I need to add to my
code to get [ReturnedStore] to be blank if the data is backspaced out of
[Store] and it is blank?

Joan


William Taylor said:
try this instead:
If Forms!SalesScreen!Returned = "Y" And Not
IsNull(Forms!SalesScreen![Store]) Then

Joan said:
Hi,
I have a form called "SalesScreen" where on the AfterUpdate event of the
[Store] control I have the following code:

Private Sub Store_AfterUpdate()
Dim db As Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("EnterStoresQuery", dbOpenDynaset)
If Forms!SalesScreen!Returned = "Y" And Forms!SalesScreen![Store] Is Not
Null Then
Forms!SalesScreen!ReturnedStore = Forms!SalesScreen!Store
Forms!SalesScreen!ReturnedSalePrice = Forms!SalesScreen!SalesPrice
End If
rs.Close
db.Close

End Sub

When I update the [Store] field and press tab, I get the followin runtime
error: "Object required". What object am I missing?

This form (displays inventory of dogs) is used by salesmen to record the
storecode in the [Store] field of a dog record when they sell a dog to a
store. Sometimes dogs are returned from stores for one reason or another,
put back into inventory and resold. When a dog is returned, the dog record
again appears on the SalesScreen with the [Store] control blank so that the
saleman can enter the storecode again when the dog is resold. Behind the
scenes, unbeknown to the salesmen, fields need to be updated such as:
ReturnedStore(store the dog is sold to the second time) and
ReturnedSalesPrice (Price the dog is sold at the second time around). These
controls are on the SalesScreen form but are invisible to the user. This
essentially is what I am trying to do with the above code. What am I doing
wrong? Any suggestions are appreciated.

Joan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top