combo box freezes after a choice has been made!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hello again everyone,
ive spent a while trying to figure this out, no luck so far and im on a time
limit (as everyone else i guess) so i dont have much more time to sort this.

My combo box on a form allows me to pick a value and does all the
calculations ive written in a VBA sub exectue perfectly but then when i try
to pick another value on it, it makes a little noise and nothing happens, i
can move around the rest of the form just fine but i cant amend that value
ive set.
It doesnt even seem to call the event when i try clicking on it again! it
just makes a litle ping noise!
However when i take some code of the VBA i notice that i can change the
value but its now not running the caluclations in the background that i need.

ive inserted in the vba code below, if you spot anything in it then id
really appreciate any ideas.
Private Sub PayOption_Click()

Me![Payment1] = Me![weeks1]
Me![Payment2] = Me![weeks2]
Me![Payment3] = Me![weeks3]
Me![Payment4] = Me![weeks4]

'when i take this if statement out then it works just fine
If Not IsNull(Me![Duration]) And Not IsNull(Me![Discount]) And Not
IsNull(Me![WeeklyRent]) Then

POption = Me![PayOption]
weeks = Me![Duration]
WeeklyRent = Me![WeeklyRent]
Discount = Me![Discount]

'calculates the rent without any discount
Me![rentalPayment] = weeks * WeeklyRent
'calls the function to calculate the total rent based on the option
number
Me![DiscountedRentalPayment] = weeks * WeeklyRent * Discount
Else
Exit Sub
End If

End Sub

with much thanks
Amit
 
just some additional info,
I've added some error catching code to it, and its come up with an:

'label not defined' error message, any ideas about that?
 
'when i take this if statement out then it works just fine
If Not IsNull(Me![Duration]) And Not IsNull(Me![Discount]) And Not
IsNull(Me![WeeklyRent]) Then

If it's the If statement that's not working, try replacing the Not IsNull()
function with Nz(), as follows:

If (Nz(Me![Duration],0)>0) And (Nz(Me![Discount],0)>0) And (Nz(Me![WeeklyRent]
,0)>0) Then
....

It does the same thing, but for some reason Access sometimes likes it better
than Not IsNull()

Sam
 
yeah i got it to work when i noticed that my error checking code wasnt
correctly programmed!

but thanks for your advise, ill try that out the next time im having
problems with isnull.

with much appreciation

Amit
 

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

Back
Top