Hi Guys,
Right I would say i need a bit of help with this one - I am quite new to VBA, but have used access DB's for a while now - but i program in other languages so can get my head around things once im shown.
Anyway, I have a database that I have setup, and is mostly working, apart from the major feature i am trying to program now.
I have attached the database as it stands while typing this for people to have a look at.
So bascially, I have a database that is populated with Purchase Order (PO) numbers, these PO numbers are linked to products, which the products each have an ID. Now there are work requests, that can take PO numbers and "claim" these PO numbers under this work request...
For example one work request requires 1x Laptop and 1x Monitor, this would then be linked to this work request, and classed as "taken" so no one else could use this PO number.
So, if you are looking at the database, click any "WR" link in the sub form, and it will open a new form.
On the right hand side is a list of products currently in stock, you will notice these are currently linked. Now what I would like this to do, when you click on the link of the product, it will add this product into this work request (add the work request ID into the PO box, and select the check box within the Purchase Orderes (requests) table.
I would like the first PO found to be added.
I have kinda adapted this code:
But its not currently working - been trying to figure it out myself, and have come up trumps.
So any advice, help or code would be great.
Right I would say i need a bit of help with this one - I am quite new to VBA, but have used access DB's for a while now - but i program in other languages so can get my head around things once im shown.
Anyway, I have a database that I have setup, and is mostly working, apart from the major feature i am trying to program now.
I have attached the database as it stands while typing this for people to have a look at.
So bascially, I have a database that is populated with Purchase Order (PO) numbers, these PO numbers are linked to products, which the products each have an ID. Now there are work requests, that can take PO numbers and "claim" these PO numbers under this work request...
For example one work request requires 1x Laptop and 1x Monitor, this would then be linked to this work request, and classed as "taken" so no one else could use this PO number.
So, if you are looking at the database, click any "WR" link in the sub form, and it will open a new form.
On the right hand side is a list of products currently in stock, you will notice these are currently linked. Now what I would like this to do, when you click on the link of the product, it will add this product into this work request (add the work request ID into the PO box, and select the check box within the Purchase Orderes (requests) table.
I would like the first PO found to be added.
I have kinda adapted this code:
Code:
Private Sub ProductName_Click()
Dim Blanket_Orders As Object
Dim rstRequests As Object
Dim fldEnumerator As Object
Dim fldColumns As Object
Set Blanket_Orders = CurrentDb
Set rstRequests = Blanket_Orders.OpenRecordset("Requests")
Set fldColumns = rstRequests.Fields
' Scan the records from beginning to each
While Not rstRequests.EOF
' Check the current column
For Each fldEnumerator In rstRequests.Fields
' If the column is named ProductID
If fldEnumerator.Name = "ProductID" Then
' If the Product ID of the current record is "9"
If fldEnumerator.Value = "9" Then
' then change its value
rstRequests.Edit
rstRequests("WRID").Value = "9999"
rstRequests.Update
End If
End If
Next
' Move to the next record and continue the same approach
rstRequests.MoveNext
Wend
End Sub
But its not currently working - been trying to figure it out myself, and have come up trumps.
So any advice, help or code would be great.