Private Sub Command1_Click()
Dim sqlsave, opsex As String
Dim comsave As New ADODB.Command
If Option1.Value = True Then
opsex = Option1.Caption
Else
opsex = Option2.Caption
End If
sqlsave = "insert into account(username,upassword,ufName,ulName,uAddress,uEmail,uTel) VALUES('" & Text1.Text & "','" & Text2.Text & "','" & Text4.Text & "','" & Text5.Text & "','" & Text6.Text & "','" & Text7.Text & "','" & Text8.Text & "')"
Conn.BeginTrans
With comsave
.ActiveConnection = Conn
.CommandType = adCmdText
.CommandText = sqlsave
.Execute
End With
If MsgBox("¤Ø³µéͧ¡Òúѹ·Ö¡¢éÍÁÙÅäËÁ", vbYesNo + vbQuestion, "¤ÓÂ×¹Âѹ") = vbYes Then
Conn.CommitTrans
MsgBox "ºÑ¹·Ö¡¢éÍÁÙÅàÃÕºÃéÍÂ", vbOKOnly + vbInformation, "¼Å¡Ò÷ӧҹ"
End If
End Sub
'¤é¹ËÒÊÁÒªÔ¡
Private Sub Command2_Click()
If Text3.Text = "" Then
MsgBox ("¡ÃسҡÃÍ¡¢éÍÁÙÅ")
Else
frmenable_search
If Combo1.Text = "ÃËÑÊÊÁÒªÔ¡" Then
rsData.MoveFirst
rsData.Find "uid = '" & Text3.Text & "'"
If rsData.EOF Then
MsgBox "äÁ辺ÃËÑÊÊÁÒªÔ¡·Õè¤é¹ËÒ"
Else
Text1.Text = rsData!UserName
Text2.Text = rsData!upassword
Text4.Text = rsData!ufName
Text5.Text = rsData!ulName
Text6.Text = rsData!uAddress
If Option1.Caption = rsData!uSex Then
Option1.Value = True
Else
Option2.Value = True
End If
Text7.Text = rsData!uEmail
Text8.Text = rsData!uTel
End If
Else
rsData.MoveFirst
rsData.Find "ufName = '" & Text3.Text & "'"
If rsData.EOF Then
MsgBox "äÁ辺ª×èÍ·Õè¤Ø³¤é¹ËÒ"
Else
Text1.Text = rsData!UserName
Text2.Text = rsData!upassword
Text4.Text = rsData!ufName
Text5.Text = rsData!ulName
Text6.Text = rsData!uAddress
Text7.Text = rsData!uEmail
Text8.Text = rsData!uTel
End If
End If
End If
End Sub
Tag : Ms Access, VBScript
Date :
2014-01-14 19:04:31
By :
kla
View :
1009
Reply :
1
No. 1
Guest
Code
Private Sub Command1_Click()
Dim sqlsave, opsex As String
Dim comsave As New ADODB.Command
If Option1.Value = True Then
opsex = Option1.Caption
Else
opsex = Option2.Caption
End If
sqlsave = "insert into account(username,upassword,ufName,ulName,uAddress,uEmail,uTel) VALUES('" & Text1.Text & "','" & Text2.Text & "','" & Text4.Text & "','" & Text5.Text & "','" & Text6.Text & "','" & Text7.Text & "','" & Text8.Text & "')"
Conn.BeginTrans
With comsave
.ActiveConnection = Conn
.CommandType = adCmdText
.CommandText = sqlsave
.Execute
End With
If MsgBox("¤Ø³µéͧ¡Òúѹ·Ö¡¢éÍÁÙÅäËÁ", vbYesNo + vbQuestion, "¤ÓÂ×¹Âѹ") = vbYes Then
Conn.CommitTrans
MsgBox "ºÑ¹·Ö¡¢éÍÁÙÅàÃÕºÃéÍÂ", vbOKOnly + vbInformation, "¼Å¡Ò÷ӧҹ"
End If
End Sub
'¤é¹ËÒÊÁÒªÔ¡
Private Sub Command2_Click()
If Text3.Text = "" Then
MsgBox ("¡ÃسҡÃÍ¡¢éÍÁÙÅ")
Else
frmenable_search
If Combo1.Text = "ÃËÑÊÊÁÒªÔ¡" Then
rsData.MoveFirst
rsData.Find "uid = '" & Text3.Text & "'"
If rsData.EOF Then
MsgBox "äÁ辺ÃËÑÊÊÁÒªÔ¡·Õè¤é¹ËÒ"
Else
Text1.Text = rsData!UserName
Text2.Text = rsData!upassword
Text4.Text = rsData!ufName
Text5.Text = rsData!ulName
Text6.Text = rsData!uAddress
If Option1.Caption = rsData!uSex Then
Option1.Value = True
Else
Option2.Value = True
End If
Text7.Text = rsData!uEmail
Text8.Text = rsData!uTel
End If
Else
rsData.MoveFirst
rsData.Find "ufName = '" & Text3.Text & "'"
If rsData.EOF Then
MsgBox "äÁ辺ª×èÍ·Õè¤Ø³¤é¹ËÒ"
Else
Text1.Text = rsData!UserName
Text2.Text = rsData!upassword
Text4.Text = rsData!ufName
Text5.Text = rsData!ulName
Text6.Text = rsData!uAddress
Text7.Text = rsData!uEmail
Text8.Text = rsData!uTel
End If
End If
End If
End Sub