if then else

Smee

Well-Known Member
Licensed User
Longtime User
hi,
Is there something wrong with this code?

Reader.New1
command.CommandText= "SELECT ProductName,SellPrice FROM [Products] WHERE ProductNo ='" & ProdCode & "'"
reader.Value=Command.ExecuteReader

If reader.ReadNextRow=True Then
SlblDescription.Text = Reader.GetValue(0)
ProdPrice= Reader.GetValue(1)
Else
StxtQty.Text=0
ProdPrice=0
StxtProdCode.Text=""
StxtProdCode.Focus
End If

Reader.Close


The program drops through ok to the if statement but if the condition is false it does not drop to the else part
:sign0104:

This also does not work for the else. what am i doing wrong?


If tblBarcodes.RowCount>0 Then
ProductCode=StxtProdCode.Text
GetProduct(ProductCode)
Else
Msgbox("Barcode Not Recognised","",cMsgboxOK,cMsgboxExclamation)
StxtProdCode.Text=""
StxtProdCode.Focus
End If
 
Last edited:

Smee

Well-Known Member
Licensed User
Longtime User
Hi Ariel,

Thanks for the reply. As is so often the case in learning new stuff i was misunderstanding the relationship with setting the focus on a control and the firing of the event. I changed code in other modules and now it 'seems' to work. I will be testing further

Thanks again

Joe
:sign0161::sign0161:
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…