VERSION 5.00 Begin VB.Form articlectrl Caption = "เลขทะเบียนดรรชนีวารสาร" ClientHeight = 2520 ClientLeft = 60 ClientTop = 450 ClientWidth = 5910 LinkTopic = "Form1" MDIChild = -1 'True ScaleHeight = 2520 ScaleWidth = 5910 Begin VB.CommandButton Cmdcan BackColor = &H00C0FFC0& Caption = "Cancel" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 735 Left = 3120 Style = 1 'Graphical TabIndex = 5 Top = 1560 Width = 1335 End Begin VB.CommandButton Cmdexit BackColor = &H00C0FFC0& Caption = "Exit" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 735 Left = 4440 Style = 1 'Graphical TabIndex = 3 Top = 1560 Width = 1335 End Begin VB.CommandButton Cmdsave BackColor = &H00C0FFC0& Caption = "Save" Enabled = 0 'False BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 735 Left = 1800 Style = 1 'Graphical TabIndex = 2 Top = 1560 Width = 1335 End Begin VB.CommandButton Cmdedit BackColor = &H00C0FFC0& Caption = "Edit" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 735 Left = 480 Style = 1 'Graphical TabIndex = 1 Top = 1560 Width = 1335 End Begin VB.Frame Frame2 Caption = "เลขทะเบียน" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 1215 Left = 1680 TabIndex = 0 Top = 120 Width = 2535 Begin VB.TextBox Text_regctrl BackColor = &H00C0FFFF& BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00C00000& Height = 375 Left = 480 Locked = -1 'True TabIndex = 4 Top = 480 Width = 1575 End End End Attribute VB_Name = "articlectrl" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim Conn As New ADODB.Connection Dim artctrltab As New ADODB.Recordset Dim pasa As String Private Sub Cmdcan_Click() Text_regctrl.Locked = True Cmdedit.Enabled = True Cmdsave.Enabled = False Set Conn = New ADODB.Connection Conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _ & "SERVER=192.168.1.15;" _ & "DATABASE=magazine;" _ & "UID=chaiya;" _ & "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384 Conn.CursorLocation = adUseClient Conn.Mode = adModeUnknown Conn.Open Set artctrltab = New ADODB.Recordset With artctrltab If .State = adStateOpen Then .Close .CursorLocation = adUseClient .Open "Select * From artctrl ", Conn, adOpenForwardOnly, adLockReadOnly If Not .EOF Then Text_regctrl.Text = .Fields(0).Value .Close End With Set artctrltab = Nothing Conn.Close Set Conn = Nothing End Sub Private Sub Cmdexit_Click() If Conn.State = adStateOpen Then Conn.Close Set Conn = Nothing Unload Me End Sub Private Sub Cmdedit_Click() Text_regctrl.Locked = False Cmdedit.Enabled = False Cmdsave.Enabled = True Text_regctrl.SelStart = Len(Text_regctrl) Text_regctrl.SetFocus End Sub Private Sub Cmdsave_Click() Text_regctrl.Locked = True Cmdedit.Enabled = True Cmdsave.Enabled = False Set Conn = New ADODB.Connection Conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _ & "SERVER=192.168.1.15;" _ & "DATABASE=magazine;" _ & "UID=chaiya;" _ & "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384 Conn.CursorLocation = adUseClient Conn.Mode = adModeUnknown Conn.Open Set artctrltab = New ADODB.Recordset With artctrltab If .State = adStateOpen Then .Close .CursorLocation = adUseClient .Open "Select * From artctrl ", Conn, adOpenForwardOnly, adLockOptimistic If Not .EOF Then .Fields(0).Value = Text_regctrl.Text .Update End If .Close End With Set artctrltab = Nothing Conn.Close Set Conn = Nothing End Sub Private Sub Command1_Click() End Sub Private Sub Form_Resize() Set Conn = New ADODB.Connection Conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _ & "SERVER=192.168.1.15;" _ & "DATABASE=magazine;" _ & "UID=chaiya;" _ & "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384 Conn.CursorLocation = adUseClient Conn.Mode = adModeUnknown Conn.Open Set artctrltab = New ADODB.Recordset With artctrltab If .State = adStateOpen Then .Close .CursorLocation = adUseClient .Open "Select * From artctrl ", Conn, adOpenForwardOnly, adLockReadOnly If Not .EOF Then Text_regctrl.Text = .Fields(0).Value .Close End With Set artctrltab = Nothing Conn.Close Set Conn = Nothing End Sub Private Sub Form_Unload(Cancel As Integer) If Conn.State = adStateOpen Then Conn.Close Set Conn = Nothing End Sub