Guest User

Untitled

a guest
Nov 23rd, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. Private Sub CommandButton1_Click()
  2. MsgBox "Welcome to ---Tool"
  3. Dim Rno As Variant
  4. Dim cn As ADODB.Connection
  5. Dim rs As Object
  6. Dim mno As String
  7. Dim rngname As Range
  8.  
  9. Rno = InputBox("Enter Receipt No", "Receipt Number")
  10. MsgBox "Receipt Number entered is " & Rno & " that you entered"
  11. Set cn = New ADODB.Connection
  12. connectionString = "provider= msdaora; data source =XX; user id=XX; password =XX"
  13. cn.Open connectionString
  14. Set rs = New ADODB.Recordset
  15. rs.ActiveConnection = cn
  16. Set rs = CreateObject("ADODB.RECORDSET")
  17. mno = "SELECT state FROM table name WHERE receipt_no in (""'RNO'"");"
  18.  
  19. 'cn.Execute mno
  20.  
  21. rs.ActiveConnection = cn
  22. 'rs.Open mno
  23. Set rs = cn.Execute(mno)
  24. Sheets(1).Range("A2").CopyFromRecordset rs
  25.  
  26. MsgBox " state is " & Sheets(1).Range("a2") & " from the database"
  27. MsgBox "Do you want to change state from 1 to 5?"
  28. query of update
  29. rs.Close
  30. cn.Close
  31. Set cn = Nothing
  32. End Sub
Add Comment
Please, Sign In to add comment