Good source for example code and syntax?

back2basic

Registered User.
Local time
Today, 12:38
Joined
Feb 19, 2013
Messages
113
Hi its been a while since of written in Basic....15 years. I am doing fairly well...having fun too, but can anyone point to a good source for researching code examples that gives good explanations and examples of statements and proper syntax.?
 
Thank you, nice site you have....Expert.
By the time I get my answer from Research my application will be obsolete. Would you help me to find out why the below statement will not work?

This statement alone works fine
Code:
QTY_Available = Me![cboMaterial_ID].Column(3) ' Get the quantity available of the material selected.
But if I try to get two fields and subtract it will not work...Must be my syntax but why?

Code:
QTY_Available = Me![cboMaterial_ID].Column(3) - Me![cboMaterial_ID].Column(4)
 
Looks okay. What is the column count property of the combo? And the row source?
 
I am not sure why you use Bang (!) rather than a Dot (.)..

So, do you get an error? What do you mean by it does not work?

Try..
Code:
QTY_Available = CLng(Me.[cboMaterial_ID].Column(3)) - CLng(Me.[cboMaterial_ID].Column(4))
 
Column count property is 4. Row Source is as follows: Not sure I understand this. Seems like it should be 6 based on the Row source? In any event, the two columns call (3& 4) are in the right spot. Should I change it to six?

Pr2 -eugin & Baldy as always thank you for your help. Your responses are extremely valuable. To answer your questions, I do not know the difference between Me! and Me. Learning as I go and enjoying the challenge.

Pr2, your suggestion above still did not work. Get an error 13, type mis-match and both variables are numbers.Also, I have taken all your suggestion into consideration and am currently updating and changing the DB table and look-up DB.

Code:
SELECT  [Materials].[Material_ID], [Materials].[Material_name],  [Materials].[Part_number], Materials.[Stock_Quantity],  Materials.[Issued_Quantity], Materials.[Secured Item],  Materials.[Serial_Number] FROM Materials WHERE  materials.[Stock_Quantity]>0 ORDER BY [Material_name];
 
Yes, column count needs to reflect the actual count, and is probably why your code fails, as 4 is the 5th actual column.
 
:banghead::banghead::banghead:!!

Agree, Should be 6 and has been changed...still sames error, type mismatch 13

Even still, column count starts with 0. so pointers are still valid correct?

Could the problem be this is a open record and the Combox can only pull one field of information per statement?
 
SH#T! Just realized it. Problem solved.. Dawned on me, the Issued Quantity field is blank.."Null" need to go back and fill in all fields with zero to start. Hence type mis-match.
 
The CLng() would error on Null. You could have gotten around it with

QTY_Available = Nz(Me![cboMaterial_ID].Column(3), 0) - Nz(Me![cboMaterial_ID].Column(4), 0)

But of course not having Nulls is the ideal solution.
 
Ok Thank you, I agree and want to make this statement as fail safe as possible by accounting for Nulls. but when I put a null or blank in Column 4 "Issued_quantity" and use this statement:

QTY_Available = Nz(Me![cboMaterial_ID].Column(3), 0) - Nz(Me![cboMaterial_ID].Column(4), 0)

I get a type mismatch error again. Something must be jacked up in the row source property if this should work.
 

Users who are viewing this thread

Back
Top Bottom