Solved

else if statment & print

Posted on 2002-05-11
5
132 Views
Last Modified: 2010-05-02
Hi
How can I use the if ststment in VB I tried to use it but it gives me error

Aslo how I can print which command Im using ADODC connection and I want to print All the fields with thier labels

Please tell me ASAP



 If invoice.Text1.Text = "" Then
    invoice.Text1.Text = Text1.Text
    invoice.Text2.Text = Text7.Text
    invoice.Text5.Text = Text2.Text
    invoice.Text6.Text = Text12.Text
    Adodc1.Recordset.Update
    invoice.Text4.Text = Date
   
     num = Val(Text9.Text)
     num = num - Text12.Text
     Text9.Text = num
     Text9.SetFocus
     Adodc1.Recordset.Save
     Frame2.Visible = False
     Parts.Hide
Else if//////////////I does not work
    invoice.Text7.Text = Text1.Text
    invoice.Text12.Text = Text7.Text
    invoice.Text10.Text = Text2.Text
    invoice.Text11.Text = Text12.Text
   
   
   
Else if  invoice.Text7.Text = (0) Then///////doesnot work
    invoice.Text15.Text = Text1.Text
    invoice.Text18.Text = Text7.Text
    invoice.Text16.Text = Text2.Text
    invoice.Text17.Text = Text12.Text
    invoice.Show
     End If
0
Comment
Question by:furious581
5 Comments
 
LVL 1

Expert Comment

by:RandyB30
ID: 7003693
you have no condition listed for this else if

Else if//////////////I does not work
   invoice.Text7.Text = Text1.Text
   invoice.Text12.Text = Text7.Text
   invoice.Text10.Text = Text2.Text
   invoice.Text11.Text = Text12.Text


try:


Else if PLACE CONDITION HERE Then
   invoice.Text7.Text = Text1.Text
   invoice.Text12.Text = Text7.Text
   invoice.Text10.Text = Text2.Text
   invoice.Text11.Text = Text12.Text


Randy
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 120 total points
ID: 7003787
Else if  invoice.Text7.Text = (0) Then///////doesnot work
   invoice.Text15.Text = Text1.Text
   invoice.Text18.Text = Text7.Text
   invoice.Text16.Text = Text2.Text
   invoice.Text17.Text = Text12.Text
   invoice.Show
    End If

change to
Else if  invoice.Text7.Text = "0" Then///////doesnot work
   invoice.Text15.Text = Text1.Text
   invoice.Text18.Text = Text7.Text
   invoice.Text16.Text = Text2.Text
   invoice.Text17.Text = Text12.Text
   invoice.Show
    End If

a comparison of .text field requires a string.


An option could be
If invoice.Text1.Text = "" Then
  YOUR CODE FOR THIS PART
Elseif  invoice.Text7.Text = "0"
  YOUR CODE FROM THIS PART
Else
  YOUR CODE FROM THE ELSEIF WITHOUT THE COMDITION
end if


mlmcc
0
 
LVL 44

Expert Comment

by:bruintje
ID: 7003802
and use elseif instead of else if
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7003921
And use Select case if possible instead of a bunch of elseif.
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 7004721
your code should look like this:

Elseif  invoice.Text7.Text = "0" Then
  invoice.Text15.Text = Text1.Text
  invoice.Text18.Text = Text7.Text
  invoice.Text16.Text = Text2.Text
  invoice.Text17.Text = Text12.Text
  invoice.Show
End If

It is also a VERY goopd idea to NAME your text boxes with MEANINGFUL names, rather that keep the DEAFULT names (Text1 does not mean anything where txtInterestRate or txtValue does).  Just a suggestion.

Arthur Wood

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now