กระทู้เก่าบอร์ด อ.Yeadram
19,176 68
URL.หัวข้อ /
URL
คำสั่ง print report ที่ต่างภาษากัน ทำอย่างไรค่ะ
รบกวนท่านอาจารย์และท่านผู้รู้หน่อยค่ะ พอดีมีลูกค้า 2 ประเภท คือ ใช้ บิลภาษาไทย กับภาษา อังกฤษ ค่ะ เวลา ปริ้น รีพอท จึงต้อง สั่งปริ้น ตามแบบของลูกค้า ลองใช้ คำสั่ง dlookup ไป ก็ยังไม่สามารถทำได้ ค่ะ รบกวนท่านผู้รู้ช่วยแก้ได้ไหมค่ะ
function ที่หนูพยายามเขียน ประมาณนี้ค่ะ แค่ทำยังไงๆ โปรแกรม ก็ ปริ้นแต่รีพอท ภาษาไทย
Function PrintInvoice(OrderID As Long) As Boolean
Dim Result
Result = DLookup("[Language]", "Customers", "Language")
If Result = "TH" Then
DoCmd.OpenReport "InvoiceTH", acViewPreview, , "[Order ID]=" & OrderID, acDialog
Else
DoCmd.OpenReport "InvoiceEN", acViewPreview, , "[Order ID]=" & OrderID, acDialog
End If
End Function
รบกวนหน่อยนะค่ะ
function ที่หนูพยายามเขียน ประมาณนี้ค่ะ แค่ทำยังไงๆ โปรแกรม ก็ ปริ้นแต่รีพอท ภาษาไทย
Function PrintInvoice(OrderID As Long) As Boolean
Dim Result
Result = DLookup("[Language]", "Customers", "Language")
If Result = "TH" Then
DoCmd.OpenReport "InvoiceTH", acViewPreview, , "[Order ID]=" & OrderID, acDialog
Else
DoCmd.OpenReport "InvoiceEN", acViewPreview, , "[Order ID]=" & OrderID, acDialog
End If
End Function
รบกวนหน่อยนะค่ะ
68 Reply in this Topic. Dispaly 4 pages and you are on page number 4
61 @R13490
ได้แล้วค่ะ อาจารย์เก่งมากเลยค่ะ ;)
62 @R13533
อาจารย์คะ ต่อจากเรื่อง ตอบเรื่อง (ป้อนคำอะไรก็ได้ในส่วนของเท็กซ์ของคอมโบ้บ็อกซ์ แล้วให้แสดงส่วนของลิสท์ตามคำที่ค้นหา)
Code Key up ในForm Customer Order ค่ะ
Option Compare Database
Option Explicit
Sub SetDefaultShippingAddress()
If IsNull(Me![Customer ID]) Then
ClearShippingAddress
Else
Dim rsw As New RecordsetWrapper
If rsw.OpenRecordset("Customers Extended", "[ID] = " & Me.Customer_ID) Then
Me.[InvoiceNO] = DMax("[InvoiceNumber]", "[Orders]") + 1
With rsw.Recordset
Me![Ship Name] = ![Contact Name]
Me![Ship Address] = ![Address]
End With
End If
End If
End Sub
Private Sub cmdDeleteOrder_Click()
If IsNull(Me![Order ID]) Then
Beep
ElseIf Me![Status ID] = Shipped_CustomerOrder Or Me![Status ID] = Closed_CustomerOrder Then
MsgBoxOKOnly CannotCancelShippedOrder
ElseIf MsgBoxYesNo(CancelOrderConfirmPrompt) Then
If CustomerOrders.Delete(Me![Order ID]) Then
MsgBoxOKOnly CancelOrderSuccess
eh.TryToCloseObject
Else
MsgBoxOKOnly CancelOrderFailure
End If
End If
End Sub
Private Sub cmdClearAddress_Click()
ClearShippingAddress
End Sub
Private Sub ClearShippingAddress()
Me![Ship Name] = Null
Me![Ship Address] = Null
Me![Ship City] = Null
Me![Ship State/Province] = Null
Me![Ship ZIP/Postal Code] = Null
Me![Ship Country/Region] = Null
End Sub
Private Sub cmdCompleteOrder_Click()
If Me![Status ID] <> Shipped_CustomerOrder Then
MsgBoxOKOnly OrderMustBeShippedToClose
ElseIf ValidateOrder(Closed_CustomerOrder) Then
Me![Status ID] = Closed_CustomerOrder
eh.TryToSaveRecord
MsgBoxOKOnly OrderMarkedClosed
SetFormState
End If
End Sub
Private Sub cmdCreateInvoice_Click()
Dim OrderID As Long
Dim InvoiceID As Long
OrderID = Nz(Me![Order ID], 0)
' Gracefully exit if invoice already created
If CustomerOrders.IsInvoiced(OrderID) Then
If MsgBoxYesNo(OrderAlreadyInvoiced) Then
CustomerOrders.PrintInvoice Me.Customer_ID, OrderID
End If
ElseIf ValidateOrder(Invoiced_CustomerOrder) Then
' Create Invoice Record
If CustomerOrders.CreateInvoice(OrderID, 0, InvoiceID) Then
' Mark all Order Items Invoiced
' Need to change Inventory Status to SOLD from HOLD
Dim rsw As New RecordsetWrapper
With rsw.GetRecordsetClone(Me.sbfOrderDetails.Form.Recordset)
While Not .EOF
If Not IsNull(![Inventory ID]) And ![Status ID] = OnHold_OrderItemStatus Then
rsw.Edit
![Status ID] = Invoiced_OrderItemStatus
rsw.Update
Inventory.HoldToSold ![Inventory ID]
End If
rsw.MoveNext
Wend
End With
' Print the Invoice
CustomerOrders.PrintInvoice Me.Customer_ID, OrderID
SetFormState
End If
End If
End Sub
Private Sub cmdShipOrder_Click()
If Not CustomerOrders.IsInvoiced(Nz(Me![Order ID], 0)) Then
MsgBoxOKOnly CannotShipNotInvoiced
ElseIf Not ValidateShipping() Then
MsgBoxOKOnly ShippingNotComplete
Else
Me![Status ID] = Shipped_CustomerOrder
If IsNull(Me![Shipped Date]) Then
Me![Shipped Date] = Date
End If
eh.TryToSaveRecord
SetFormState
End If
End Sub
Private Sub Customer_ID_AfterUpdate()
SetFormState False
If Not IsNull(Me![Customer ID]) Then
SetDefaultShippingAddress
End If
End Sub
Private Sub Customer_ID_KeyUp(KeyCode As Integer, Shift As Integer)
Me.Customer_ID.RowSource = "SELECT [ID], [Company], [Address For Ship], [ID] FROM [Customers Extended] WHERE [ID],[Company], [Address For Ship] like '*" & Me.Customer_ID.Text & "*' ORDER BY [Company], [Address For Ship]"
Me.Customer_ID.Dropdown
End Sub
Private Sub Form_Current()
SetFormState
End Sub
Private Sub Form_Load()
SetFormState
End Sub
Function GetDefaultSalesPersonID() As Long
GetDefaultSalesPersonID = GetCurrentUserID()
End Function
Function ValidateShipping() As Boolean
If Nz(Me![Shipping Fee]) = "" Then Exit Function
ValidateShipping = True
End Function
Function ValidatePaymentInfo() As Boolean
If IsNull(Me![Payment Type]) Then Exit Function
If IsNull(Me![Paid Date]) Then Exit Function
ValidatePaymentInfo = True
End Function
Sub SetFormState(Optional fChangeFocus As Boolean = True)
If fChangeFocus Then Me.Customer_ID.SetFocus
Dim Status As CustomerOrderStatusEnum
Status = Nz(Me![Status ID], New_CustomerOrder)
TabCtlOrderData.Enabled = Not IsNull(Me![Customer ID])
Me.cmdCreateInvoice.Enabled = (Status = New_CustomerOrder)
Me.cmdShipOrder.Enabled = (Status = New_CustomerOrder) Or (Status = Invoiced_CustomerOrder)
Me.cmdDeleteOrder.Enabled = (Status = New_CustomerOrder) Or (Status = Invoiced_CustomerOrder)
Me.cmdCompleteOrder.Enabled = (Status <> Closed_CustomerOrder)
Me.[Order Details_Page].Enabled = (Status = New_CustomerOrder)
Me.[Shipping Information_Page].Enabled = (Status = New_CustomerOrder)
Me.[Payment Information_Page].Enabled = (Status <> Closed_CustomerOrder)
Me.Customer_ID.Locked = (Status <> New_CustomerOrder)
Me.Employee_ID.Locked = (Status <> New_CustomerOrder)
Me.sbfOrderDetails.Locked = (Status <> New_CustomerOrder)
End Sub
Function ValidateOrder(Validation_OrderStatus As CustomerOrderStatusEnum) As Boolean
If IsNull(Me![Customer ID]) Then
MsgBoxOKOnly MustSpecifyCustomer
ElseIf IsNull(Me![Employee ID]) Then
MsgBoxOKOnly MustSpecifySalesPerson
ElseIf Not ValidateShipping() Then
MsgBoxOKOnly ShippingNotComplete
Else
If Validation_OrderStatus = Closed_CustomerOrder Then
If Not ValidatePaymentInfo() Then
MsgBoxOKOnly PaymentInfoNotComplete
Exit Function
End If
End If
Dim rsw As New RecordsetWrapper
With rsw.GetRecordsetClone(Me.sbfOrderDetails.Form.Recordset)
' Check that we have at least one specified line items
If .RecordCount = 0 Then
MsgBoxOKOnly OrderDoesNotContainLineItems
Else
' Check all that all line items have allocated inventory
Dim LineItemCount As Integer
Dim Status As OrderItemStatusEnum
LineItemCount = 0
While Not .EOF
LineItemCount = LineItemCount + 1
Status = Nz(![Status ID], None_OrderItemStatus)
If Status <> OnHold_OrderItemStatus And Status <> Invoiced_OrderItemStatus Then
MsgBoxOKOnly MustBeAllocatedBeforeInvoicing
Exit Function
End If
rsw.MoveNext
Wend
ValidateOrder = True
End If
End With
End If
End Function
Code Key up ในForm Customer Order ค่ะ
Option Compare Database
Option Explicit
Sub SetDefaultShippingAddress()
If IsNull(Me![Customer ID]) Then
ClearShippingAddress
Else
Dim rsw As New RecordsetWrapper
If rsw.OpenRecordset("Customers Extended", "[ID] = " & Me.Customer_ID) Then
Me.[InvoiceNO] = DMax("[InvoiceNumber]", "[Orders]") + 1
With rsw.Recordset
Me![Ship Name] = ![Contact Name]
Me![Ship Address] = ![Address]
End With
End If
End If
End Sub
Private Sub cmdDeleteOrder_Click()
If IsNull(Me![Order ID]) Then
Beep
ElseIf Me![Status ID] = Shipped_CustomerOrder Or Me![Status ID] = Closed_CustomerOrder Then
MsgBoxOKOnly CannotCancelShippedOrder
ElseIf MsgBoxYesNo(CancelOrderConfirmPrompt) Then
If CustomerOrders.Delete(Me![Order ID]) Then
MsgBoxOKOnly CancelOrderSuccess
eh.TryToCloseObject
Else
MsgBoxOKOnly CancelOrderFailure
End If
End If
End Sub
Private Sub cmdClearAddress_Click()
ClearShippingAddress
End Sub
Private Sub ClearShippingAddress()
Me![Ship Name] = Null
Me![Ship Address] = Null
Me![Ship City] = Null
Me![Ship State/Province] = Null
Me![Ship ZIP/Postal Code] = Null
Me![Ship Country/Region] = Null
End Sub
Private Sub cmdCompleteOrder_Click()
If Me![Status ID] <> Shipped_CustomerOrder Then
MsgBoxOKOnly OrderMustBeShippedToClose
ElseIf ValidateOrder(Closed_CustomerOrder) Then
Me![Status ID] = Closed_CustomerOrder
eh.TryToSaveRecord
MsgBoxOKOnly OrderMarkedClosed
SetFormState
End If
End Sub
Private Sub cmdCreateInvoice_Click()
Dim OrderID As Long
Dim InvoiceID As Long
OrderID = Nz(Me![Order ID], 0)
' Gracefully exit if invoice already created
If CustomerOrders.IsInvoiced(OrderID) Then
If MsgBoxYesNo(OrderAlreadyInvoiced) Then
CustomerOrders.PrintInvoice Me.Customer_ID, OrderID
End If
ElseIf ValidateOrder(Invoiced_CustomerOrder) Then
' Create Invoice Record
If CustomerOrders.CreateInvoice(OrderID, 0, InvoiceID) Then
' Mark all Order Items Invoiced
' Need to change Inventory Status to SOLD from HOLD
Dim rsw As New RecordsetWrapper
With rsw.GetRecordsetClone(Me.sbfOrderDetails.Form.Recordset)
While Not .EOF
If Not IsNull(![Inventory ID]) And ![Status ID] = OnHold_OrderItemStatus Then
rsw.Edit
![Status ID] = Invoiced_OrderItemStatus
rsw.Update
Inventory.HoldToSold ![Inventory ID]
End If
rsw.MoveNext
Wend
End With
' Print the Invoice
CustomerOrders.PrintInvoice Me.Customer_ID, OrderID
SetFormState
End If
End If
End Sub
Private Sub cmdShipOrder_Click()
If Not CustomerOrders.IsInvoiced(Nz(Me![Order ID], 0)) Then
MsgBoxOKOnly CannotShipNotInvoiced
ElseIf Not ValidateShipping() Then
MsgBoxOKOnly ShippingNotComplete
Else
Me![Status ID] = Shipped_CustomerOrder
If IsNull(Me![Shipped Date]) Then
Me![Shipped Date] = Date
End If
eh.TryToSaveRecord
SetFormState
End If
End Sub
Private Sub Customer_ID_AfterUpdate()
SetFormState False
If Not IsNull(Me![Customer ID]) Then
SetDefaultShippingAddress
End If
End Sub
Private Sub Customer_ID_KeyUp(KeyCode As Integer, Shift As Integer)
Me.Customer_ID.RowSource = "SELECT [ID], [Company], [Address For Ship], [ID] FROM [Customers Extended] WHERE [ID],[Company], [Address For Ship] like '*" & Me.Customer_ID.Text & "*' ORDER BY [Company], [Address For Ship]"
Me.Customer_ID.Dropdown
End Sub
Private Sub Form_Current()
SetFormState
End Sub
Private Sub Form_Load()
SetFormState
End Sub
Function GetDefaultSalesPersonID() As Long
GetDefaultSalesPersonID = GetCurrentUserID()
End Function
Function ValidateShipping() As Boolean
If Nz(Me![Shipping Fee]) = "" Then Exit Function
ValidateShipping = True
End Function
Function ValidatePaymentInfo() As Boolean
If IsNull(Me![Payment Type]) Then Exit Function
If IsNull(Me![Paid Date]) Then Exit Function
ValidatePaymentInfo = True
End Function
Sub SetFormState(Optional fChangeFocus As Boolean = True)
If fChangeFocus Then Me.Customer_ID.SetFocus
Dim Status As CustomerOrderStatusEnum
Status = Nz(Me![Status ID], New_CustomerOrder)
TabCtlOrderData.Enabled = Not IsNull(Me![Customer ID])
Me.cmdCreateInvoice.Enabled = (Status = New_CustomerOrder)
Me.cmdShipOrder.Enabled = (Status = New_CustomerOrder) Or (Status = Invoiced_CustomerOrder)
Me.cmdDeleteOrder.Enabled = (Status = New_CustomerOrder) Or (Status = Invoiced_CustomerOrder)
Me.cmdCompleteOrder.Enabled = (Status <> Closed_CustomerOrder)
Me.[Order Details_Page].Enabled = (Status = New_CustomerOrder)
Me.[Shipping Information_Page].Enabled = (Status = New_CustomerOrder)
Me.[Payment Information_Page].Enabled = (Status <> Closed_CustomerOrder)
Me.Customer_ID.Locked = (Status <> New_CustomerOrder)
Me.Employee_ID.Locked = (Status <> New_CustomerOrder)
Me.sbfOrderDetails.Locked = (Status <> New_CustomerOrder)
End Sub
Function ValidateOrder(Validation_OrderStatus As CustomerOrderStatusEnum) As Boolean
If IsNull(Me![Customer ID]) Then
MsgBoxOKOnly MustSpecifyCustomer
ElseIf IsNull(Me![Employee ID]) Then
MsgBoxOKOnly MustSpecifySalesPerson
ElseIf Not ValidateShipping() Then
MsgBoxOKOnly ShippingNotComplete
Else
If Validation_OrderStatus = Closed_CustomerOrder Then
If Not ValidatePaymentInfo() Then
MsgBoxOKOnly PaymentInfoNotComplete
Exit Function
End If
End If
Dim rsw As New RecordsetWrapper
With rsw.GetRecordsetClone(Me.sbfOrderDetails.Form.Recordset)
' Check that we have at least one specified line items
If .RecordCount = 0 Then
MsgBoxOKOnly OrderDoesNotContainLineItems
Else
' Check all that all line items have allocated inventory
Dim LineItemCount As Integer
Dim Status As OrderItemStatusEnum
LineItemCount = 0
While Not .EOF
LineItemCount = LineItemCount + 1
Status = Nz(![Status ID], None_OrderItemStatus)
If Status <> OnHold_OrderItemStatus And Status <> Invoiced_OrderItemStatus Then
MsgBoxOKOnly MustBeAllocatedBeforeInvoicing
Exit Function
End If
rsw.MoveNext
Wend
ValidateOrder = True
End If
End With
End If
End Function
63 @R13534
ผลออกมาเป็นแบบนี้ ค่ะ
64 @R13535
[IMG ]images/image-not-found.png[/IMG]
control ตามนี้ค่ะ
control ตามนี้ค่ะ
65 @R13536
ข้อมล column
[IMG ]images/image-not-found.png[/IMG]
[IMG ]images/image-not-found.png[/IMG]
66 @R13537
ตรงcontrol source หนูใส่code นี้ไว้นะคะ พอดี รูปขี้นซ้ำอีกแล้ว
SELECT [ID], [Company], [Address For Ship], [ID] FROM [Customers Extended] WHERE [ID]<>Nz(Form!ID,0) ORDER BY [Company], [Address For Ship];
กดครั้งแรกจะขึ้นข้อมูลที่เราต้องการทั้งหมดค่ะแต่พอพิมค้นหาก็ไม่ขึ้นอะไรเลย
SELECT [ID], [Company], [Address For Ship], [ID] FROM [Customers Extended] WHERE [ID]<>Nz(Form!ID,0) ORDER BY [Company], [Address For Ship];
กดครั้งแรกจะขึ้นข้อมูลที่เราต้องการทั้งหมดค่ะแต่พอพิมค้นหาก็ไม่ขึ้นอะไรเลย
67 @R13538
ข่าวดีค่ะ เรื่องที่หนูถามก่อนหน้านี้ เรื่องเลือกลูกค้าแล้วตรงช่องสินค้าแสดงขึ้นมาเฉพาะสินค้าของลูกค้ารายนั้น หนูลองแก้ไปมา ใช้codeของอาจารย์ สำเร็จ ทำได้แล้วนะคะ เหลือเรื่อง การพิมค้นหากับเรื่องภาษา ที่หนูยังไม่สามารถจริงๆค่ะ รบกวนอาจารย์ อีกหน่อยนะคะ เรื่องภาษาทำไงก็ไม่ได้อยู่ดี พิมยังไงก็ขึ้นแต่รีพอทไทย ;(
68 @R13751
กระทู้นี้ ต่อไปยัง http://www.thai-access.com/yeadram_view.php?topic_id=2969
Time: 0.2956s