Some Explanation with Access Query

firoz.raj

Registered User.
Local time
Tomorrow, 02:05
Joined
Dec 4, 2008
Messages
41
can anybody tell why this Ms Access query is not working .Kindly let me know the idea.Any help would be highly appreciated.
Code:
SELECT AccessRole.emp_ID, AccessRole.FormID
FROM AccessRole
WHERE AccessRole.emp_ID='281' and AccessRole.Form_id='4';
 
ID fields are usually numbers, not texts....
try:
WHERE AccessRole.emp_ID=281 and AccessRole.Form_id=4;
 
I Simple want if ReadForm is selected.means if bit field is checked .then i want to see the corresponding value.but Nothing Comes .when i runs the query.Kindly let me know the idea.Any help would be highly appreciated.
Readform is a Yes/No field.
Code:
SELECT AccessRole.emp_ID, AccessRole.FormID, AccessRole.ReadForm
FROM AccessRole
WHERE ((AccessRole.Readform=1));
 
Check boxes return a value of "True" or -1 when checked and a value of "False" or 0 when unchecked
 
So your query could like like;
Code:
SELECT AccessRole.emp_ID, AccessRole.FormID, AccessRole.ReadForm
FROM AccessRole
WHERE ((AccessRole.Readform=-1));
or
Code:
SELECT AccessRole.emp_ID, AccessRole.FormID, AccessRole.ReadForm
FROM AccessRole
WHERE ((AccessRole.Readform="True"));
 
Can you tell me ?Why this Sql Query is not working.When i tried to save .it
is Saying Extra) in Query .Kindly let me know the idea.Any help would be highly appreciated.Kindly find the attachment also.
Code:
SELECT PurchaseOrder.PO_ID, PurchaseOrder.RefNo, Suppliers.sup_name, Materials.Productname, Materials.unit, PurchaseOrderDetail.item_code, PurchaseOrderDetail.item_type, PurchaseOrderDetail.Quantity, PurchaseOrderDetail.UnitPrice, Materials.openingBalance FROM (PurchaseOrder INNER JOIN Suppliers ON PurchaseOrder.sup_ID = Suppliers.sup_id) INNER JOIN (Materials INNER JOIN PurchaseOrderDetail ON (Materials.item_type = PurchaseOrderDetail.item_type) AND (Materials.item_code = PurchaseOrderDetail.item_code)) ON (PurchaseOrder.RefNo = PurchaseOrderDetail.RefNo) AND (PurchaseOrder.PO_ID = PurchaseOrderDetail.PO_ID) WHERE (((PurchaseOrder.PO_ID)=) AND ((PurchaseOrder.RefNo)=));
 

Attachments

  • AccessSqlissue.jpg
    AccessSqlissue.jpg
    60.4 KB · Views: 154
It would appear that you have an extra right parenthesis. Print out your SQL and then match up each set of parenthesis, starting from the inside of each set, and working your way out until you have found the mismatch.
 
Still issue .Kindly let me know .why it is not working.
Code:
"SELECT PurchaseOrder.PO_ID, PurchaseOrder.RefNo, Suppliers.sup_name, Materials.Productname, Materials.unit, PurchaseOrderDetail.item_code, " & _
           "PurchaseOrderDetail.item_type, PurchaseOrderDetail.Quantity, PurchaseOrderDetail.UnitPrice, Materials.openingBalance " & _
           "FROM (PurchaseOrder INNER JOIN Suppliers ON PurchaseOrder.sup_ID = Suppliers.sup_id) INNER JOIN (Materials INNER JOIN PurchaseOrderDetail " & _
           "ON (Materials.item_type = PurchaseOrderDetail.item_type) AND (Materials.item_code = PurchaseOrderDetail.item_code)) " & _
           "ON (PurchaseOrder.RefNo = PurchaseOrderDetail.RefNo) AND (PurchaseOrder.PO_ID = PurchaseOrderDetail.PO_ID) " & _
           "WHERE (((PurchaseOrder.PO_ID)=" & sPO_ID & ") AND ((PurchaseOrder.RefNo)=" & sRefNo & "));"
 
First lets try and make this a little more readable...
Code:
strSQL = ""
strSQL = strSQL & " SELECT PurchaseOrder.PO_ID"
strSQL = strSQL & " , PurchaseOrder.RefNo"
strSQL = strSQL & " , Suppliers.sup_name"
strSQL = strSQL & " , Materials.Productname"
strSQL = strSQL & " , Materials.unit"
strSQL = strSQL & " , PurchaseOrderDetail.item_code"
strSQL = strSQL & " , PurchaseOrderDetail.item_type"
strSQL = strSQL & " , PurchaseOrderDetail.Quantity"
strSQL = strSQL & " , PurchaseOrderDetail.UnitPrice"
strSQL = strSQL & " , Materials.openingBalance"
strSQL = strSQL & " FROM (           PurchaseOrder "
strSQL = strSQL & "       INNER JOIN Suppliers ON PurchaseOrder.sup_ID = Suppliers.sup_id)"
strSQL = strSQL & "       INNER JOIN (Materials "
strSQL = strSQL & "       INNER JOIN PurchaseOrderDetail"
strSQL = strSQL & "                            ON (     Materials.item_type = PurchaseOrderDetail.item_type)"
strSQL = strSQL & "                                AND (Materials.item_code = PurchaseOrderDetail.item_code))"
strSQL = strSQL & "                    ON (     PurchaseOrder.RefNo = PurchaseOrderDetail.RefNo)"
strSQL = strSQL & "                        AND (PurchaseOrder.PO_ID = PurchaseOrderDetail.PO_ID)"
strSQL = strSQL & " WHERE (((PurchaseOrder.PO_ID)=" & sPO_ID & ")"
strSQL = strSQL & "    AND ((PurchaseOrder.RefNo)=" & sRefNo & "));"

Assuming sPO_ID and sRefNo are variables from elsewhere in this code, I cannot (off hand) see anything wrong with this SQL...

Even a small re-write, to increase 'normalization' of the query... Dont show me any problems.
Whats the error your getting?

Code:
strSQL = ""
strSQL = strSQL & " SELECT PurchaseOrder.PO_ID"
strSQL = strSQL & " ,      PurchaseOrder.RefNo"
strSQL = strSQL & " ,      Suppliers.sup_name"
strSQL = strSQL & " ,      Materials.Productname"
strSQL = strSQL & " ,      Materials.unit"
strSQL = strSQL & " ,      PurchaseOrderDetail.item_code"
strSQL = strSQL & " ,      PurchaseOrderDetail.item_type"
strSQL = strSQL & " ,      PurchaseOrderDetail.Quantity"
strSQL = strSQL & " ,      PurchaseOrderDetail.UnitPrice"
strSQL = strSQL & " ,      Materials.openingBalance"
strSQL = strSQL & " FROM             PurchaseOrder "
strSQL = strSQL & "       INNER JOIN Suppliers 	                ON PurchaseOrder.sup_ID = Suppliers.sup_id"
strSQL = strSQL & "       INNER JOIN PurchaseOrderDetail        ON PurchaseOrder.RefNo = PurchaseOrderDetail.RefNo"
strSQL = strSQL & "                                            AND PurchaseOrder.PO_ID = PurchaseOrderDetail.PO_ID"
strSQL = strSQL & "       INNER JOIN Materials                  ON PurchaseOrderDetail.item_type = Materials.item_type"
strSQL = strSQL & "                                            AND PurchaseOrderDetail.item_code = Materials.item_code"
strSQL = strSQL & " WHERE  PurchaseOrder.PO_ID=" & sPO_ID & ""
strSQL = strSQL & "    AND PurchaseOrder.RefNo=" & sRefNo & ";"
 
can you tell me in my material table itemcode together with itemtype is a unique.i want to see the max itemcode.in the following way suppose last no is 542 and itemtype is m.then in query 542 is come.same way last no is 543 and itemtype is p.then 543p.So since itemcode together with itemtype is a unique.so let me know the idea.any help would be highly appreciated.Kindly find the attachment also.the following way last itemcode is comming.but suppose last unique term is 543p then 543p should come.along with itemtype .
Code:
SELECT MAX([item_Code]) AS max_number
FROM Materials;
 

Attachments

  • Materialstable.jpg
    Materialstable.jpg
    63.9 KB · Views: 140
Your 2 columns combine to be unique arent they?

Or do you want to combine the two columns into one? which you would do like so:
ItemCodeAndType: Item_code & Item_type

Or do you simply want the maximum number per type?
SELECT itemtype, MAX([item_Code]) AS max_number
FROM Materials
group by itemtype;

?? Your question isnt exactly clear or well formatted so I am left confused.
Also the minimum of 'effort' would atleast be to use capitols where applicable and spacing and such :(
 
Can you demonstrate any example of Append query of Ms Access.Kindly let me know the idea.Any help woud be highly appreciated.i want to see
how can i use the append query.Kindly find the attachment also.kindly let me know the idea.Any help would be highly appreciated.
 

Attachments

  • AppendQueryIssue.jpg
    AppendQueryIssue.jpg
    62.2 KB · Views: 162
O M G

Erm, you make it append like your doing, it will ask what table to append to, you fill in the table.

Then in the design there will be an extra line "append to", here you fill in the columns where the data needs to go... thats all there is to it.
 
why the following query is not working ?.i want to see the Maximum no of itemcode.records on the basis of parameter.if i put p.it show those records which itemtype p.in the same way if i put M.it should show the Maximum No of itemcode on the basis of sItemType parameter.Which is matching with m.means Kindly find the attachment also.and let me know the idea.in the moment nothing is comming when i put M,P OR T as a parameter.Sql itself is explaining what is needed to do.
Code:
PARAMETERS sItemType Text ( 50 );
SELECT Max([Materials.item_code]) AS max_number
FROM Materials
WHERE (((Materials.item_type)='" & sItemType & "'));
 

Attachments

  • ParametersIssue1.jpg
    ParametersIssue1.jpg
    42.6 KB · Views: 123
  • parameterissue2.jpg
    parameterissue2.jpg
    33.9 KB · Views: 127
If you have a text parameter there is no need to quote it, you only need do that if you have a variable that your substituting not with a parameter...

WHERE (((Materials.item_type)=[sItemType]));
Will make it work just fine.
 

Users who are viewing this thread

Back
Top Bottom