Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub CommandButton1_Click()
- MsgBox "Welcome to ---Tool"
- Dim Rno As Variant
- Dim cn As ADODB.Connection
- Dim rs As Object
- Dim mno As String
- Dim rngname As Range
- Rno = InputBox("Enter Receipt No", "Receipt Number")
- MsgBox "Receipt Number entered is " & Rno & " that you entered"
- Set cn = New ADODB.Connection
- connectionString = "provider= msdaora; data source =XX; user id=XX; password =XX"
- cn.Open connectionString
- Set rs = New ADODB.Recordset
- rs.ActiveConnection = cn
- Set rs = CreateObject("ADODB.RECORDSET")
- mno = "SELECT state FROM table name WHERE receipt_no in (""'RNO'"");"
- 'cn.Execute mno
- rs.ActiveConnection = cn
- 'rs.Open mno
- Set rs = cn.Execute(mno)
- Sheets(1).Range("A2").CopyFromRecordset rs
- MsgBox " state is " & Sheets(1).Range("a2") & " from the database"
- MsgBox "Do you want to change state from 1 to 5?"
- query of update
- rs.Close
- cn.Close
- Set cn = Nothing
- End Sub
Add Comment
Please, Sign In to add comment