473,406 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to add control in VB

kirubagari
158 100+
Dear experts,

I need help on add control in VB..Im develping program and it will be read in MDB file..I have to avoid the double qoute in that program if the item description have the double code..For Eg.Laptop computer and if double qoute present on that i have to avoid that and output without the double code.


The second thing is i have control the item length and if the item length more than 40..i have to give some warning message..How i can do on that?
Kindly help me on this..Thanks


Expand|Select|Wrap|Line Numbers
  1. Dim db As DAO.Database
  2. Dim rs1 As DAO.Recordset
  3. Dim rs2 As DAO.Recordset
  4. Dim rs3 As DAO.Recordset
  5. Dim ProjID As DAO.Recordset
  6. Dim strSQL As String
  7. Dim intErrNo As Integer
  8. Dim updCounter As Integer
  9. Dim updStatus As Boolean
  10.  
  11.  
  12. Function InsertIntoMaster()
  13.     Set db = CurrentDb
  14.  
  15.     intErrNo = 0
  16.  
  17.     strSQL = "SELECT * FROM Project_Counter WHERE Desc_Project='Chinastk'"
  18.     Set ProjID = db.OpenRecordset(strSQL)
  19.  
  20.     strSQL = "SELECT * FROM NewItem WHERE Updated=0"
  21.     Set rs1 = db.OpenRecordset(strSQL)
  22.  
  23.     strSQL = "DELETE * FROM [Outlet Item List]"
  24.     db.Execute strSQL
  25.  
  26.     Do While Not rs1.EOF
  27.         updStatus = True
  28.  
  29.         strSQL = "SELECT * FROM dbo_ChinaStk_ProdCat "
  30.         strSQL = strSQL & "WHERE PCCode='" & rs1("PCCode") & "' "
  31.         Set rs2 = db.OpenRecordset(strSQL)
  32.         If Not rs2.EOF Then
  33.             strHQMfgCode = rs2("PCBarCode") & Format(rs2("BarCodeCounter"), "0000000")
  34.             Set rs2 = Nothing
  35.         Else
  36.             intErrNo = intErrNo + 1
  37.             Set rs2 = Nothing
  38.             GoTo NextRec
  39.         End If
  40.  
  41.         strSQL = "SELECT * FROM dbo_OP_Product_SubCategory "
  42.         strSQL = strSQL & "WHERE Product_Category='" & rs1("PCCode") & "' "
  43.         strSQL = strSQL & "AND Product_CategorySub='" & rs1("PSCCode") & "' "
  44.         Set rs2 = db.OpenRecordset(strSQL)
  45.         If rs2.EOF Then
  46.             intErrNo = intErrNo + 1
  47.             Set rs2 = Nothing
  48.             GoTo NextRec
  49.         End If
  50.         Set rs2 = Nothing
  51.  
  52.         strItemDesc = ""
  53.         For intCount = 1 To Len(rs1("ItemDesc"))
  54.             If Mid(rs1("ItemDesc"), intCount, 1) <> "'" Then
  55.                 strItemDesc = strItemDesc & Mid(rs1("ItemDesc"), intCount, 1)
  56.             End If
  57.         Next
  58.  
  59.         strSQL = "INSERT INTO dbo_ChinaStk_Master (PrjID, "
  60.         strSQL = strSQL & "SetNo,PCCode,PBCode,PSCCode,ItemDesc,"
  61.         strSQL = strSQL & "UOM,StdCost,RSP,MthlyExpectSalesQty,CustomCode,"
  62.         strSQL = strSQL & "MfgBarCode,QtyOfUnit,ItemType,MeasurementUnit,UnitCode) "
  63.         strSQL = strSQL & "VALUES("
  64.         strSQL = strSQL & ProjID("Project_Counter") & ",'"
  65.         strSQL = strSQL & rs1("AccSet") & "','"
  66.         strSQL = strSQL & rs1("PCCode") & "','"
  67.         strSQL = strSQL & rs1("PBCode") & "','"
  68.         strSQL = strSQL & rs1("PSCCode") & "','"
  69.         strSQL = strSQL & strItemDesc & "','"
  70.         strSQL = strSQL & IIf(Len(Trim(rs1("Unit"))) = 0 Or IsNull(rs1("Unit")), " ", rs1("Unit")) & "',"
  71.         strSQL = strSQL & rs1("StdCost") & ","
  72.         strSQL = strSQL & rs1("RSP") & ","
  73.         strSQL = strSQL & IIf(Len(Trim(rs1("ExpectedSalesQty"))) = 0 Or IsNull(rs1("ExpectedSalesQty")), 1, rs1("ExpectedSalesQty")) & ",'"
  74.         strSQL = strSQL & IIf(Len(Trim(rs1("CustomCode"))) = 0 Or IsNull(rs1("CustomCode")), " ", rs1("CustomCode")) & "','"
  75.         strSQL = strSQL & strHQMfgCode & "',"
  76.         strSQL = strSQL & rs1("QtyOfUnit") & ",'"
  77.         strSQL = strSQL & rs1("ItemType") & "',"
  78.         strSQL = strSQL & rs1("MeasurementUnit") & ",'"
  79.         strSQL = strSQL & rs1("UnitCode") & "'"
  80.         strSQL = strSQL & ")"
  81.         db.Execute strSQL
  82.  
  83.         strSQL = "UPDATE NewItem SET Updated=1 WHERE NewItemIndex=" & rs1("NewItemIndex")
  84.         db.Execute strSQL
  85.  
  86.         strSQL = "UPDATE dbo_ChinaStk_ProdCat SET BarCodeCounter=BarCodeCounter+1 "
  87.         strSQL = strSQL & "WHERE PCCode='" & rs1("PCCode") & "' "
  88.         db.Execute strSQL
  89.  
  90.         strSQL = "INSERT INTO [Outlet Item List] (HQMfgCode,UnitCost) "
  91.         strSQL = strSQL & "VALUES('" & strHQMfgCode & "',"
  92.         strSQL = strSQL & rs1("StdCost") & ")"
  93.         db.Execute strSQL
  94. NextRec:
  95.         rs1.MoveNext
  96.     Loop
  97.  
  98.     If updStatus Then
  99.         strSQL = "UPDATE Project_Counter SET Project_Counter = Project_Counter+1 WHERE Desc_Project='Chinastk'"
  100.         db.Execute strSQL
  101.     End If
  102.  
  103.  
  104.     Set rs1 = Nothing
  105.     Set rs2 = Nothing
  106.     Set ProjID = Nothing
  107.     Set db = Nothing
  108.  
  109.  
  110.  
  111.     DoCmd.OpenQuery "qrymoveProcessesNewItem"
  112.     'DoCmd.OpenQuery "qryDeleteNewItem"
  113.     If intErrNo > 0 Then
  114.         MsgBox intErrNo & " record(s) cannot be process due to the invalid Product Category or Product Subcategory, please correct it!"
  115.     End If
  116. End Function
  117.  
  118.  
  119.  
Nov 16 '10 #1
1 1166
Guido Geurs
767 Expert 512MB
to replace " in string: this replaces: " in text1 with: _

Expand|Select|Wrap|Line Numbers
  1. Text2 = Replace(Text1, """", "_")
to check the lenght of a string:

Expand|Select|Wrap|Line Numbers
  1. If Len(Text1) > 40 Then MsgBox "To Long"
Nov 16 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Bruce Rusk | last post by:
I'm using Stephen Lebans' RTF2 control in a report, and have discovered what may be a slight bug in it. I have a lot of non-Western language (Chinese) text in my RTF field, and such records get...
6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
3
by: Eric | last post by:
I have built a composite user web control that I want to create dynamically. The form will contain a variable number of these controls and as well some of the contents of the user web control...
2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
5
by: serge calderara | last post by:
Dear all, I am new in asp.net and prepare myself for exam I still have dificulties to understand the difference between server control and HTML control. Okey things whcih are clear are the fact...
2
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is...
14
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control...
2
by: rn5a | last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with the IDs 'txt1' & 'txt2' respectively. To use this user control in an ASPX page, the following Register directive will be...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
1
GaryTexmo
by: GaryTexmo | last post by:
In my last insight, http://bytes.com/topic/c-sharp/insights/909141-object-scaling-varying-resolutions, I talked about scaling objects to a form's size so that it would always draw with the correct...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.