473,396 Members | 1,998 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,396 software developers and data experts.

SQL in ACCESS and VB6

PLS.... Help!!!
--------------------------------------------------------------------------------

hi commnunity

i have problem with sql,
i have created a table in Access Named TABLE1 in TABLE1 i have EmployeeNumber, Section, Posotion;

i assigned EmployeeNumber as text1.text
Section as text2.text
Posotion as text3.text
i have buttons name ADDrecord,

here is my code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. Dim EmployeeNumber As String
  3. Dim Section As String
  4. Dim Postion As String
  5.  
  6. Dim strSQL As String
  7. Text1.Text = EmployeeNumber
  8. Text2.Text = Section 
  9. Text3.Text = Position
  10.  
  11. strSQL = "INSERT INTO TABLE1 (EmployeeNumber, Section, Position) " & _
  12. "VALUES('" & [EmployeeNumber] & "','" & [Section] & _
  13. "'," & [Position] & ")"
  14. Adodc1.RecordSource = strSQL
  15. Adodc1.Recordset.Save
  16. Adodc1.Refresh
  17.  
  18.  
  19.  
  20. End Sub
  21.  
  22.  
  23. Private Sub Form_Load()
  24. Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Maan\My Documents\db4.mdb;Persist Security Info=False"
  25. Adodc1.RecordSource = "SELECT * FROM Table1"
  26. End Sub

is this Correct? pls.. make an example for me...


thank you in advance

Julius

--------------------------------------------------------------------------------
Dec 12 '06 #1
3 2039
MMcCarthy
14,534 Expert Mod 8TB
Try this ...

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. Dim EmployeeNumber As String
  3. Dim Section As String
  4. Dim Postion As String
  5. Dim strSQL As String
  6.  
  7. ' Wrong way around Julius, should be
  8.    EmployeeNumber = Text1.Text
  9.    Section = Text2.Text
  10.    Position = Text3.Text
  11.  
  12. ' no square brackets around EmployeeNumber, Section or Position
  13. ' as these are variables and not field or control names.
  14.    strSQL = "INSERT INTO TABLE1 (EmployeeNumber, Section, Position) " & _
  15.    "VALUES ('" & EmployeeNumber & "','" & Section & "','" & Position & "')"
  16.  
  17.    DoCmd.RunSQL strSQL
  18.  
  19. Adodc1.RecordSource = strSQL
  20. Adodc1.Recordset.Save
  21. Adodc1.Refresh
  22.  
  23. End Sub
  24.  
Mary
Dec 12 '06 #2
Try this ...

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. Dim EmployeeNumber As String
  3. Dim Section As String
  4. Dim Postion As String
  5. Dim strSQL As String
  6.  
  7. ' Wrong way around Julius, should be
  8.    EmployeeNumber = Text1.Text
  9.    Section = Text2.Text
  10.    Position = Text3.Text
  11.  
  12. ' no square brackets around EmployeeNumber, Section or Position
  13. ' as these are variables and not field or control names.
  14.    strSQL = "INSERT INTO TABLE1 (EmployeeNumber, Section, Position) " & _
  15.    "VALUES ('" & EmployeeNumber & "','" & Section & "','" & Position & "')"
  16.  
  17.    DoCmd.RunSQL strSQL
  18.  
  19. Adodc1.RecordSource = strSQL
  20. Adodc1.Recordset.Save
  21. Adodc1.Refresh
  22.  
  23. End Sub
  24.  
Mary

Thans mary, but there an erro about Refresh, well anyway i'll try to fix eat, but if i cant , may be i'll go to you ... thanks Godbless you

julius
Dec 12 '06 #3
MMcCarthy
14,534 Expert Mod 8TB
Thans mary, but there an erro about Refresh, well anyway i'll try to fix eat, but if i cant , may be i'll go to you ... thanks Godbless you

julius
Try replacing Refresh with Requery
Dec 12 '06 #4

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

Similar topics

63
by: Jerome | last post by:
Hi, I'm a bit confused ... when would I rather write an database application using MS Access and Visual Basic and when (and why) would I rather write it using Visual Studio .Net? Is it as easy...
13
by: bill | last post by:
I am trying to convince a client that dotNet is preferable to an Access project (ADP/ADE). This client currently has a large, pure Access MDB solution with 30+ users, which needs to be upgraded....
1
by: Dave | last post by:
Hello NG, Regarding access-declarations and member using-declarations as used to change the access level of an inherited base member... Two things need to be considered when determining an...
13
by: Simon Bailey | last post by:
I am a newcomer to databases and am not sure which DBMS to use. I have a very simplified knowledge of databases overall. I would very much appreciate a (simplifed) message explaining the advantages...
0
by: Frederick Noronha \(FN\) | last post by:
---------- Forwarded message ---------- Solutions to Everyday User Interface and Programming Problems O'Reilly Releases "Access Cookbook, Second Edition" Sebastopol, CA--Neither reference book...
20
by: Olav.NET | last post by:
I am a .NET/C++ developer who is supposed to do some work with Access. I do not know much about it except for the DB part. Questions: *1* I am looking for INTENSIVE books to get quickly up to...
64
by: John | last post by:
Hi What future does access have after the release of vs 2005/sql 2005? MS doesn't seem to have done anything major with access lately and presumably hoping that everyone migrates to vs/sql. ...
1
by: com | last post by:
Extreme Web Reports 2005 - Soft30.com The wizard scans the specified MS Access database and records information such as report names, parameters and subqueries. ......
17
by: Mell via AccessMonster.com | last post by:
Is there a way to find out where an application was created from? i.e. - work or home i.e. - if application sits on a (work) server/network, the IT people know the application is sitting...
37
by: jasmith | last post by:
How will Access fair in a year? Two years? .... The new version of Access seems to service non programmers as a wizard interface to quickly create databases via a fancy wizard. Furthermore, why...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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.