0
votes

I am not from IT major (material engineering tbh), pardon me if my question is not really clear.

I am currently studying the MS Access 2013, and right now creating a table with details in:

Table details.

The structure of the table is here:

+----+--------+---------+--------------+-----------+---------+-----------+
| ID |  Order |  Vendor |  Attachments |  Customer |  AWB no |  Due Date |
+----+--------+---------+--------------+-----------+---------+-----------+

I created a new form, added a button to open this form and created report with macros, and used it to create a report.

I want to create a report only using data from 1 row of the table, but instead the report contains all data from table, just like the normal report.

Any suggestion how to make 1 report from only data from 1 row?

Please see this for report example:

Report template

Update : I tried to follow some instructions for "print one record" and found this VBA code :

Option Compare Database

Private Sub BttnPrint_Click()
Dim strReportName As String
Dim StrCriteria As String

If NewRecord Then
    MsgBox "This record contains no data, Please select a record to print or save this record" _
         , vbInformation, "Invalid Action"
    Exit Sub

Else
strReportName = "REPORT"

 StrCriteria = "[ID]= " & Me![ID]

       DoCmd.OpenReport strReportName, acViewPreview, , StrCriteria
   End If

End Sub

This code embedded in the "print" button on the form. This code can create report based on only one record, however I cannot switch to another record, stuck in one record only no matter which record I open. What should I do if I want to create report for another records?

2

2 Answers

0
votes

I don't understand why you are creating 3 identical tables, perhaps I am not understanding your scenario. But you can select the data gathered and also which tables to get the data from by using the Create -> Form Wizard tool.

From what I can see from the table data given, your database should have around 5 tables.

tbl_Customers (id, name, surname ... further customer details)
tbl_Orders(id, customer_id, date ... further order details)
tbl_Attachments(id, price, vendor_id... further attachments details)
tbl_Order_Attachments(id, order_id, attachment_id, quantity... further desired details)
tbl_Vendors(id, name, ... further vendor details)

0
votes

To open the report make a button in your form and use the event "on click" and write this code:

DoCmd.OpenReport report_name, acViewPreview, , condition"

eg. :

DoCmd.OpenReport "rpt_Demo", acViewPreview, , "City='London'"

Make sure you write two colons after the word acViewPreview .

In the condition field you can select your own criteria.