473,513 Members | 2,391 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Select case problem

codeCruncher
8 New Member
Using VB6, MS Access 97.
This function is supposed to insert the data if the table is empty or if it is not, delete the data and replace it with the new data in the new table. However; what happens is that it automatically exits the sub and displays the error (which is not supposed to happen unless there is no data to insert[table1 =no data]). Can anyone help? Thank you.

This is my code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.  
  3.   Dim cnn As New ADODB.Connection
  4.   Dim c
  5.   Dim I As Integer
  6.   Dim sqlstring As String
  7.  
  8.   'open connection
  9.   cnn.Open _
  10.       "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data source=C:\RMIV\RMIV.mdb;" & _
  11.       "Jet OLEDB:Engine Type=4"
  12.  
  13.   'On Error GoTo lblError
  14.   SetHourGlass Me
  15.   sqlstring = "INSERT INTO [LOKEYEW] SELECT [Table1].* FROM [Table1]"
  16.   ResetMouse Me
  17.   I = 1
  18.   Select Case I
  19.     Case I = 1:
  20.       'delete old data
  21.       SetHourGlass Me
  22.       sqlstring = "DELETE [LOKEYEW].* FROM [LOKEYEW];"
  23.       GoTo lblCatch
  24.     Case Else:
  25.       'no data in table to insert
  26.       ProcShowError
  27.       Exit Sub
  28.   End Select
  29.   cnn.Execute sqlstring
  30.   cnn.Close
  31.   Set cnn = Nothing
  32. lblError:
  33.   SetHourGlass Me
  34.   sqlstring = "INSERT INTO [LOKEYEW] SELECT [Table1].* FROM [Table1]"
  35.   MsgBox "Update Successful!", vbInformation, Me.Caption
  36.   ResetMouse Me
  37.   Exit Sub
  38. End Sub
Oct 9 '07 #1
2 1079
codeCruncher
8 New Member
This function has become too complicated. I redid everything, made it simpler and now it works but I still don't know how to close this thread.
Oct 9 '07 #2
Killer42
8,435 Recognized Expert Expert
Glad to see you got it sorted out. Don't worry about closing the thread.

Did you figure out why you were getting the wrong result from the posted code? I have to admit, there's some fairly strange logic in there.
Oct 10 '07 #3

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

Similar topics

17
14597
by: Newbie | last post by:
Dear friends, I am having a hard time understanding how to use a SELECT CASE in ASP. I have used it in VB but never in ASP scripting. Scenerio: I have 2 textboxes on a form that I have to...
0
1912
by: Michael | last post by:
I have a problem forcing files to download. If I select Save the document is saved with no problems. If I select "Open" the document is empty or I get a "File not found" error from the application...
3
6426
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
2
7139
by: JMCN | last post by:
hello i have your basic select case question. i created a combo box and save it as a query. so whenever the user selects the value and clicks the export button, the select case should then export...
10
2144
by: MLH | last post by:
Suppose the following... Dim A as Date A=#7/24/2005# I wish to compare value of A against 2 other values: 1) 8/1/2005 2) 9/1/2005 Which is better and why... First:
3
3378
by: mark.irwin | last post by:
Hello all, Have an issue where a redirect pushes data to a page with a select case which then redirects to another page. Problem is the redirect isnt working in 1 case. Code below: strURL =...
8
4701
by: | last post by:
Hello, This is gonna sound real daft, but how do I test a Select Case statement for variants of a theme? Here's a snippet of my code... Select Case sUsr Case "Guest", "TsInternetUser",...
2
5162
by: scole954387 | last post by:
Hi, I have a problem. I have written a SQL statement that has a nested select case statement on the 'where' clause to condition the results. ...
1
21650
by: microsoft.public.dotnet.languages.vb | last post by:
Hi All, I wanted to know whether this is possible to use multiple variables to use in the select case statement such as follows: select case dWarrExpDateMonth, dRetailDateMonth case...
1
8038
by: The.Daryl.Lu | last post by:
Hi, two parts to my problem if someone can help address either one or both: 1. I want to SELECT everything in the table if it matches the criteria when the query button is pressed (this is just...
0
7171
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
7545
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...
1
7111
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...
1
5095
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4751
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3240
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1605
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
461
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.