ElseIf txtVAT.Text <> " & IE#######% & " Then MsgBox "Please enter a valid VAT Number starting with IE ", vbExclamation, "Invalid Data" Exit Sub the above is the code i use to ensure a VAT number is entered in correctly (ie an example of a correct VAT number is IE5314569A), however, it throws the message box regardless. What would be the correct syntax? Any help would be greatly appreciated!
mcm
Posts
-
Validating a VAT number -
could not update, currently lockedWith Adodc3.Recordset .MoveFirst Do While Not .EOF cPrice = DataGrid1.Columns("Price") strProductCode = DataGrid1.Columns("ProductCode") 'updating the price table Dim updateSQL As String updateSQL = "Update Price set Price = " & cPrice & " " & _ " where PriceCode = '" & strPriceCode & "' " & _ " AND ProductCode = '" & strProductCode & "'" Set RS = Conn.Execute(updateSQL) .MoveNext Loop End With the above is code i use to update a datagrid, the only column that is not locked in the datagrid is the price column and the only other piece of code that i think may affect it is a BeforeColUpdate function checking to see only numeric values are entered...is there anything i am doing wrong? it updates the prices fine in the database, is there any way i could catch it to degrade gracefully instead of crashing out? Thanks in advance!
-
Use of apostrophe in stringThe use of apostrophes in a textbox, when using collaboration with a SQL statement causes trouble - i was wondering if theres any way to get around this - ie when inserting a value that contains an apostrophe, to omit it before using the SQL insert statement. Any help would be greatly appreciated!
-
"Operation not allowed when object is open"ElseIf optSuppOrder.Value = True Then Load deMain With deMain .SupplierOrderAudit_Grouping txtUser.Text, CDate(Text5.Text), CDate(Text6.Text) End With SupplierOrderAudit.Refresh If SupplierOrderAudit.Visible = False Then SupplierOrderAudit.Show End If End If if the above option button is chosen, the intended purpose is that the report is generated. However, occasionally, when the command button is pressed, it throws the above run time error pointing to the report line, why is this? any help would be greatly appreciated or if you need any additional info.
-
unloading a form at load timeDim checkSQL As String checkSQL = "SELECT OrderGenerate.OrderNumber, Client.Company, OrderGenerate.Completed " & _ " FROM Client INNER JOIN OrderGenerate ON Client.ClientCode = OrderGenerate.ClientCode " & _ " WHERE OrderGenerate.OrderDate= #" & dDate & "#" Set RS = Conn.Execute(checkSQL) If RS.BOF And RS.EOF Then MsgBox "No orders yet today", vbExclamation, "No records returned" Unload Me Exit Sub End If The above is code that is located at the form load of the form. if no records are returned from the SQL statement, i wish the message box to be displayed and the form to be unloaded, however on run time, it crashes "object was unloaded" - is there anything i can do to fix this? any help would be greatly appreciated!
-
VB Help filesI apologise that this may be documented already but i wish to create help files for my VB project. AT first i was looking at HTML help files and i looked up all the documentation on this. However, i heard that it is possible to create help files from VB without the need to download anything. is this possilbe? if so, where would i find information or instructions regarding it? Any help would be greatly appreciated!
-
deleting a row in a datagridto delete a row in a datagrid, i highlight the row and press a delete command button. this also works if i highlight the row and press delete on the keyboard. However, now i wish to perform calculations on the click of the delete command button. if delete on the keyboard is pressed, is there anyway to call the delete procedure? Thanks in advance!
-
operation not allowed when object is closeduSQL = "Insert Into OrderDetails2 (OrderNumber, ProductCode, ProductDesc, Quantity, UnitPrice, FullPrice) Values (" & iOrderNo & ", '" & strCode & "', '" & strDesc & "', " & iQuantity & "," & iPrice & ", " & iFullPrice & ")" Set RS = Conn.Execute(uSQL) 'MsgBox ("Adding record to the datagrid") 'refreshing the datagrid based on new info RS.Requery Me.Adodc3.Refresh Me.DataGrid2.Refresh the above is code for adding data to a datagrid. the Adodc3's recordset is the table OrderDetails2 and the datasource of the datagrid is Adodc3. However, when executed, it throws the above error - i have run the code many times before and it has never thrown this error. what is the problem? if it is referring to the RS, how do i open this to stop the error occurring?
-
displaying a checkbox in access as a checkbox in vbThe checkbox in access is called Completed. i am trying to populate a datagrid based on a SQL statement in VB, including this checkbox, but in the grid, it is only being displayed like a text field - is there anything i can do about this? here is my code for it - any help would be appreciated! Dim checkSQL As String checkSQL = "SELECT OrderGenerate.OrderNumber, Client.Company, OrderGenerate.Completed " & _ " FROM Client INNER JOIN OrderGenerate ON Client.ClientCode = OrderGenerate.ClientCode " & _ " WHERE (((OrderGenerate.OrderDate)=" & dToday & "))" Set RS = Conn.Execute(checkSQL) Adodc1.RecordSource = checkSQL DataGrid1.Visible = True Set DataGrid1.DataSource = Adodc1 Adodc1.Refresh DataGrid1.Refresh
-
report width larger then paper widthi get the above error when i try to generate a report in vb. i am using the report designer, but i have checked the report and there is not label or text field or anything lapping over page - what could be the problem? any help would be greatly appreciated!
-
disabling a row in a datagridi know that it is possible to disable a column in a datagrid by using Datagrid1.Columns("Field").Locked = true. is it equally possible to disable a row? for example, i wish to disable a row in 2 of the values in the row are the same (quantity and quantity in), but i do not know how to reference it. The only other column in the row is Product Code which is unique. is there any way to do it - thanks in advance for any help!
-
checking for a numeric value in a loopWith Adodc4.Recordset .MoveFirst Do While Not .EOF Dim strPriceCode As String strPriceCode = DataGrid1.Columns("PriceCode") Dim codeSQL As String codeSQL = "Select PriceCode " & _ " From PriceDescription " & _ " Where PriceCode = '" & strPriceCode & "'" Set RS = Conn.Execute(codeSQL) If RS.BOF And RS.EOF Then MsgBox " '" & strPriceCode & "' Price code does not exist - please try another", vbExclamation, "Invalid data" End If DataGrid1.Columns("Price") = txtTest.Text If Not IsNumeric(Me.txtTest.Text) Then MsgBox "Please enter a valid value for Quantity", vbExclamation, "Missing Quantity" Exit Sub End If Dim cPrice As Currency cPrice = DataGrid1.Columns("Price") 'updating the price table Dim updateSQL As String updateSQL = "Update Price set price = " & cPrice & " " & _ " where PriceCode = '" & strPriceCode & "' " & _ " AND ProductCode = '" & strProductCode & "'" Set RS = Conn.Execute(updateSQL) .MoveNext Loop End With to (attempt to!) explain the above code, i am saving 1 column of a datagrid, and looping through it by means of the Recordset that it is bound to at run time. However, i want to ensure that the value entered at each record is a numberic value, so it has to be included in the loop as can be seen above. However, when i try to run it ( and enter a non-numeric value to test it) i get the following error " Multiple step operation generated errors - check each status value"....is there anything i can do to fix this? if you need any additional information, please let me know! Thanks in advance!
-
MaskEdBoxpreviously, when generating reports, I entered a range of dates by means 2 textboxes. However, for the purposes of validation, i found this an inadequate way (eg it allows entry of days > 31 etc). instead i have started to use an MaskEdBox, i have set the DataFormat to Date, how do i set the format to ##/##/####? does it have similiar properties to that of the textbox? (ie MaskEdBox.Text etc)any help would be greatly appreciated, i am a newbie to this control!Thank you!
-
syntax error in update statementDim updateSQL As String updateSQL = "Update Product Set " & _ " Description = '" & txtDesc.text & "', " & _ :confused:" Where Code = '" & txtCode.Text & "'" Set RS = Conn.Execute(updateSQL) This statement executes fine when i test it in access but here, it returns the above error. I have checked that all the fields are the same as that in the database and the textboxes match aswell. Neither txtcode or txtDesc are bound to any component. What could the problem be? if you need any more information, please let me know, any help would be greatly appreciated!!
-
complicated question re editing datagriduSQL = "Insert Into OrderDetails2 (OrderNumber, ProductCode, ProductDesc, Quantity, Price) " & _ " Values (" & iOrderNo & ", '" & strCode & "', '" & strDesc & "', " & iQuantity & ", " & iUnitPrice & "," & iFullPrice & ")" Set RS = Conn.Execute(uSQL) Me.Adodc3.Refresh Me.DataGrid2.Refresh the above code is used to populated the datagrid first time round, by the click event of a command button. Price relates to UnitPrice*Quantity, which is calculated prior to the population of the grid, on the click of a command button. i cant edit the quantity in the datagrid directly due to the calculation that is required for FullPrice (ie Qty * Price). so instead i change the quantity in the datagrid (all other columns except FullPrice are set to locked) and press an "Edit" button which contains the following code: Dim strCustomerCode As String iOrderNo = txtOrderNo.Text strCustomerCode = Me.txtCustomerCode.Text strProductCode = DataGrid2.Columns("ProductCode") DataGrid2.Columns("ProductCode").Locked = True DataGrid2.Columns("ProductDesc").Locked = True iPrice = Datagrid2.Columns("UnitPrice") Dim iGridQty As Integer DataGrid2.Columns("Quantity") = iGridQty iFullPrice = iPrice * iGridQty DataGrid2.Columns("Price") = iFullPrice DataGrid2.Columns("Price").Locked = True With Adodc3.Recordset Dim editSQL As String editSQL = "Update OrderDetails2 " & _ " Set OrderDetails2.Quantity = " & iGridQty & ", " & _ " OrderDetails2.Price = " & iFullPrice & " " & _ " where OrderDetails2.ProductCode = '" & strProductCode & "' AND OrderDetails2.OrderNumber = " & iOrderNo & "" Set RS = Conn.Execute(editSQL) End With MsgBox ("Record Updated") The record updates fine in the table but when i leave the datagrid ,i get the following error message: "Cannot be updated for updating. Some values may have been changed sinse it was last read". What am i doing wrong? If you need any more information or explanation, please let me know - any help would be greatly appreciated!
-
problem updating datagridhaving performed an update in a datagrid, i get this message box: " insufficient key column information for updating or refreshing" (even though the table in the database updates successfully), why is this? Thanking you!
-
moving cursor to last (new) row in datagridon my form i have textboxes and a datagrid, each column in the datagrid relating to each of the texboxes on the form. When i click the "new" command button, i am blanking out the text in the textboxes to allow for new entry. I also want the cursor in the datagrid to point to a new row (record) (i have set the property of the datagrid to AllowAddNew), how do i do this? Thanks in advance!
-
generating report based on subgroupsi have successfully generated a report based on grouping. However, when i try to generate a report based on subgroups, i get returned with this error: "report sections do not match data source". why is this? here is my code in the form: Load deTypeCustomerReport With deTypeCustomerReport .TypeCustomerReport_Grouping CDate(Text1.Text) End With rptTypeCustomerReport.Refresh If rptTypeCustomerReport.Visible = False Then rptTypeCustomerReport.Show End If i have placed 1 field (company) in one of the group headers, the other (ProductType) in a second group header and the remainder of the fields in the detail section. any help would be greatly appreciated!
-
generating report based on parametres in Where clauseI am trying to generate a report in VB. What the report is generating is the individual product turnover in a given period (ie between 2 date values,obtained from 2textboxes), and grouped by product type. To do this, i have created a data environment, set up a connection and added a command. using the SQL builder, i have tried to create a SQL statement to satisfy the data i am trying to articulate. all the examples i have seen accept parametres in the select clause but not the Where so i dont know the syntax for what i am trying to achieve. here is the SQL: SELECT Product.Description, COUNT(OrderDetail.Quantity) AS Quantity, SUM(OrderDetail.Price) AS Price, ProductType.Description AS TypeDescription FROM Product, ProductType, OrderGenerate, OrderDetail WHERE Product .TypeCode = ProductType.TypeCode AND (OrderGenerate.OrderDate) BETWEEN = ? AND = ? and my code under the command button to generate the report is: deProductTurnover.ProductTurnover_Grouping dStart, dFinish rptProductTurnover.Show i have defined the parametres and the appropriate groups aswell. what am i doing wrong, what is the correct SQL statement? the error being returned is: "unabled to determine the parameter information for the parameters. Use the parameters Tab to specify appropriate info". any help would be greatly appreciated!
-
generating report based on values in 2textboxesi had generated a report from a query in access (ie using the query as a datasource), and that worked fine. However, now i want to run the report based on the query in the database and 2 values (ie between 2 dates) in textboxes so i have hardcoded the following SQL statement behind the command button to generate the report. However, i do not know what to do from here - the SQL statement will be a datasource and datamember for what - the data environment? the command? the report? Thanking you! SELECT DISTINCT Client.Company, OrderGenerate.OrderNumber, Sum(OrderDetail.Price) AS SumOfPrice FROM (Client INNER JOIN OrderGenerate ON Client.ClientCode=OrderGenerate.ClientCode) INNER JOIN OrderDetail ON OrderGenerate.OrderNumber=OrderDetail.OrderNo WHERE Date Between ' " & txtDateFrom.Text & "' and ' " & txtDateTo.Text & "' GROUP BY Client.Company, OrderGenerate.OrderNumber