1
ห้อง MS Access / : DAO การ insert ข้อมูล โดยการ Select จากอีก Record
« เมื่อ: 16 ก.พ. 64 , 14:43:11 »
อ้าว ลบข้อมูลออกทำไมอะครับ เผื่อจะมีประโยชน์กับคนอื่นในอนาคต
โพสต์นี้ได้รับคำขอบคุณจาก: UnKnown
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Option Compare Database
Public strText1, strText2, strText3 As Variant
Private Sub Form_Current()
Me.total = strText1 & " " & strText2 & " " & strText3
End Sub
Private Sub Text1_Change()
If Len(Me.Text1.Text) > 0 Then
strText1 = Me.Text1.Text
End If
Me.total = strText1 & " " & strText2 & " " & strText3
End Sub
Private Sub Text2_Change()
If Len(Me.Text2.Text) > 0 Then
strText2 = Me.Text2.Text
End If
Me.total = strText1 & " " & strText2 & " " & strText3
End Sub
Private Sub Text3_Change()
If Len(Me.Text3.Text) > 0 Then
strText3 = Me.Text3.Text
End If
Me.total = strText1 & " " & strText2 & " " & strText3
End Sub
Private Sub Command24_Click()
Call ClearPickingReport
DoEvents
Call AddPickingReport
End Sub
Sub ClearPickingReport()
Dim RS As DAO.Recordset
Set RS = CurrentDb.OpenRecordset("TaxRegis", dbOpenDynaset)
If Me.Dirty = True Then
Me.Dirty = False
End If
RS.MoveFirst
Do While Not RS.EOF
If RS("GetReport") = "Picking" Then
RS.Edit
RS("GetReport") = Null
RS.Update
End If
RS.MoveNext
Loop
RS.Close
Set RS = Nothing
End Sub
Sub AddPickingReport()
Dim RSt As DAO.Recordset
Set RSt = Me.RecordsetClone
RSt.MoveFirst
Do While Not RSt.EOF
If RSt("ฎีกา/ส่งตรวจ") = True Then
RSt.Edit
RSt("GetReport") = "Picking"
RSt.Update
End If
RSt.MoveNext
Loop
RSt.Close
Set RSt = Nothing
Me.Dirty = False
DoCmd.OpenReport "TaxRegis_Check_Yes", acViewPreview
End Sub
SELECT TaxRegis.* FROM TaxRegis WHERE ((Not (TaxRegis.GetReport) Is Null));
พึ่งคิดได้ว่าก็ใช้คำสั่งให้ทุกปุ่มที่มีซ่อนก่อนแล้วค่อยมาสั่งแสดงตามตัวเลขที่หลังอีกทีโค๊ด: [Select]Private Sub Text5_AfterUpdate()
Me.Command1.Visible = False
Me.Command2.Visible = False
Me.Command3.Visible = False
Me.Command4.Visible = False
GetNum = Me.Text5
Select Case GetNum
Case "1": Me.Command1.Visible = True
Case "2": Me.Command2.Visible = True
Case "3": Me.Command3.Visible = True
Case "4": Me.Command4.Visible = True
End Select
End Sub
Sub select_case()
Dim strTextName,GetString,GetNum As String
strTextName = ActiveControl.Name
GetNum = Right(strTextName, Len(strTextName) - InStrRev(strTextName, "_"))
Me("ne_" & GetNum) = Me(strTextName).Column(4)
GetString = Me(strTextName).Column(4)
Select Case GetString
Case "Undead": Me("WinNE_" & GetNum).Value = "Fire"
Case "Earth": Me("WinNE_" & GetNum).Value = "Fire"
Case "Fire": Me("WinNE_" & GetNum).Value = "Water"
Case "Water": Me("WinNE_" & GetNum).Value = "Wind"
Case "Wind": Me("WinNE_" & GetNum).Value = "Earth"
Case "Poison": Me("WinNE_" & GetNum).Value = "Holy"
Case "Shadow": Me("WinNE_" & GetNum).Value = "Holy"
Case "Holy": Me("WinNE_" & GetNum).Value = "Shadow"
Case Else: Me("WinNE_" & GetNum).Value = ""
End Select
End Sub