Hi all, if any one could help with this problem it would be much appreciated.
My Problem: I would like to be able to display "N/A" in the delivery text fields on my report where no delivery info actually exists. Displaying the necessary info where delivery info does exsist is fine, my code just seizes when it cant find any dates. Below is the code what is trying to carry out the operation. My original idea (probably a stupid one) was to say :
If myrecordsource.item.field (deliveryfield) is not = to Null then
Display delivery info
If it is = to null then
Put N/A into delivery fields on the report
Am I on the right lines or well off the mark?
Cheers
Dim cnn1 As ADODB.Connection
Set cnn1 = CurrentProject.Connection
Dim myRecordSet As New ADODB.Recordset
myRecordSet.ActiveConnection = cnn1
Dim mySQL As String
mySQL = "SELECT DeliveryID, OrderID, DeliveryDate, DeliveryTime"
mySQL = mySQL + " FROM DeliveryTBL"
mySQL = mySQL + " WHERE OrderID = " & Me.OrderID.Value & " "
myRecordSet.Open mySQL
If myRecordSet.Fields.Item("DeliveryID") <> Null Then
Reports![OrderInvoiceRPT]!DeliveryRefText = myRecordSet.Fields.Item("DeliveryID")
Reports![OrderInvoiceRPT]!DeliveryDateText = myRecordSet.Fields.Item("DeliveryDate")
Reports![OrderInvoiceRPT]!DeliveryTimeText = myRecordSet.Fields.Item("DeliveryTime")
Else
Reports![OrderInvoiceRPT]!DeliveryRefText.Value = "N/A"
Reports![OrderInvoiceRPT]!DeliveryDateText.Value = "N/A"
Reports![OrderInvoiceRPT]!DeliveryTimeText.Value = "N/A"
End If
My Problem: I would like to be able to display "N/A" in the delivery text fields on my report where no delivery info actually exists. Displaying the necessary info where delivery info does exsist is fine, my code just seizes when it cant find any dates. Below is the code what is trying to carry out the operation. My original idea (probably a stupid one) was to say :
If myrecordsource.item.field (deliveryfield) is not = to Null then
Display delivery info
If it is = to null then
Put N/A into delivery fields on the report
Am I on the right lines or well off the mark?
Cheers
Dim cnn1 As ADODB.Connection
Set cnn1 = CurrentProject.Connection
Dim myRecordSet As New ADODB.Recordset
myRecordSet.ActiveConnection = cnn1
Dim mySQL As String
mySQL = "SELECT DeliveryID, OrderID, DeliveryDate, DeliveryTime"
mySQL = mySQL + " FROM DeliveryTBL"
mySQL = mySQL + " WHERE OrderID = " & Me.OrderID.Value & " "
myRecordSet.Open mySQL
If myRecordSet.Fields.Item("DeliveryID") <> Null Then
Reports![OrderInvoiceRPT]!DeliveryRefText = myRecordSet.Fields.Item("DeliveryID")
Reports![OrderInvoiceRPT]!DeliveryDateText = myRecordSet.Fields.Item("DeliveryDate")
Reports![OrderInvoiceRPT]!DeliveryTimeText = myRecordSet.Fields.Item("DeliveryTime")
Else
Reports![OrderInvoiceRPT]!DeliveryRefText.Value = "N/A"
Reports![OrderInvoiceRPT]!DeliveryDateText.Value = "N/A"
Reports![OrderInvoiceRPT]!DeliveryTimeText.Value = "N/A"
End If
Last edited: