sunshine076
Registered User.
- Local time
- Today, 12:29
- Joined
- Apr 6, 2009
- Messages
- 160
Been working on a new program that is working however when it reaches the case select it skips case 1 moves to case 2 checks it and skips the rest of the cases and exits the cycle. Variable myID will only stay on the first row of data and will not check the rest of the excel spreadsheet. What this is doing is a spreadsheet will update a database when a button is clicked. Case 2 does work I have tried this and it does update the DB.
Below is my code:
Below is my code:
Code:
Option Explicit
Public Function BottomRow(ColumnNumber As Integer)
BottomRow = Cells(Rows.Count, ColumnNumber).End(xlUp).Row
End Function
Private Sub UpdateDatabase()
Dim x As Integer
Dim Data As Integer
Dim db As Database, rs As Recordset
Set db = OpenDatabase("Y:\Quality\Databases\eims.mdb")
Set rs = db.OpenRecordset("M15", dbOpenTable)
x = 2
Data = 2
myID = Cells(x, 13).Value
Do
If rs.Fields("ID") = myID Then
rs.Edit
With rs
Select Case Data
Case Is = 1
.Fields("CharNum") = Cells(x, Data).Value
.Update
Exit Do
Case Is = 2
.Fields("Desc") = Cells(x, Data).Value
.Update
Exit Do
Case Is = 3
.Fields("OpNum") = Cells(x, Data).Value
.Update
Exit Do
Case Is = 4
.Fields("Loc") = Cells(x, Data).Value
.Update
Exit Do
Case Is = 5
.Fields("LSL") = Cells(x, Data).Value
.Update
Exit Do
Case Is = 6
.Fields("USL") = Cells(x, Data).Value
.Update
Exit Do
Case Is = 7
.Fields("GELSL") = Cells(x, Data).Value
.Update
Exit Do
Case Is = 8
.Fields("GEUSL") = Cells(x, Data).Value
.Update
Exit Do
Case Is = 9
.Fields("LESSA") = Cells(x, Data).Value
.Update
Exit Do
Case Is = 10
.Fields("MOREA") = Cells(x, Data).Value
.Update
Exit Do
Case Is = 11
.Fields("LESSB") = Cells(x, Data).Value
.Update
Exit Do
Case Is = 12
.Fields("MOREB") = Cells(x, Data).Value
.Update
Exit Do
End Select
End With
End If
rs.MoveNext
Loop Until rs.EOF
Set rs = Nothing
Set db = Nothing
End Sub
Last edited by a moderator: