HI am new to Access and know very basic things. (1 Viewer)

rd_sheth

New member
Local time
Today, 19:00
Joined
Sep 10, 2023
Messages
9
Was actually trying some database for my company.

I have Form in which have below feilds:

Field: Rate
Field: ConvertRate
than have 2 Combobox
1st Combobox: Rate per Unit
2nd Combobox: Convert Rate Unit

Now i want to compare 2 Combobox and than get value of ConvertRate

Example

If ComboBox Rate Per Unit value selected kg
and ComboBox Convert Rate Unit value Selected kg too then Field ConvertRate should be equal to Field Rate
but if
ComboBox Convert Rate Unit Value selected m2 than the Feild ConvertRate should calculate (Rate /1000) * gsm (GSM is also Field).
and if ComboBox Convert Rate is other than values mentioned above than the Field ConvertRate should Calculate (Rate / 1000)

Wrote code as under:

Private Sub convert_Unit_Rate_AfterUpdate()
If [convert_Unit_Rate] = [Rate_per_Unit] Then
[ConvertRate] = [Rate]
ElseIf [convert_Unit_Rate] = "m2" And [Rate_per_Unit] = "kg" Then
[ConvertRate] = [Rate] / 1000 * [GSM]
Else
[ConvertRate] = [Rate] / 1000
End If
End Sub


in above code ElseIf part is not working... No Error... kindly suggest....
 

Jon

Access World Site Owner
Staff member
Local time
Today, 14:30
Joined
Sep 28, 1999
Messages
7,397
Welcome to Access World! We're so happy to have you join us as a member of our community. As the most active Microsoft Access discussion forum on the internet, with posts dating back more than 20 years, we have a wealth of knowledge and experience to share with you.

We're a friendly and helpful community, so don't hesitate to ask any questions you have or share your own experiences with Access. We're here to support you and help you get the most out of this powerful database program.

To get started, we recommend reading the post linked below. It contains important information for all new users of the forum:

https://www.access-programmers.co.uk/forums/threads/new-member-read-me-first.223250/

We hope you have a great time participating in the discussion and learning from other Access enthusiasts. We look forward to having you around!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:30
Joined
Oct 29, 2018
Messages
21,473
Hi. Welcome to AWF!

Please consider posting your question in the appropriate forum and show us the properties of your Combobox.
 

jdraw

Super Moderator
Staff member
Local time
Today, 09:30
Joined
Jan 23, 2006
Messages
15,379
Welcome to AWF! This area of the site is intended for welcoming/introduction. Since you have a specific issue, I suggest you create a new post in the Forms area. I would also recommend that you describe your issue in plain English and also tell us a little about the business and process involved. Sometimes it helps with communication if you show a specific example highlighting the Before and intended After values of a process.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:30
Joined
Feb 28, 2001
Messages
27,186
The first thing I would do for this specific problem is to learn how to set breakpoints and how to single-step. If you put a breakpoint on the line of your IF statement, the code breaks BEFORE attempting the IF. At that point you can hover the mouse-cursor over the items tested in your code to see their values. And you can single-step through each line to see what it does. That might enlighten you as to why things aren't working. I looked at the code and don't see a syntax error which means it is probably a data error.

For future reference, don't EVER tell us "not working" and leave it at that. Tell us WHAT is not working and HOW YOU KNOW that it is not working. As jdraw suggests, it might be good to say "this is what I want" as well as "this is what I got instead." Tell us about any error messages or wrong answers or the machine explodes in a cloud of microchips or some such incorrect behavior.
 

Users who are viewing this thread

Top Bottom