Combo Result adds check mark in another DB?

B

Bill

Hi,

On a form is a combobox which selects a Purchase order number.

The Purchase order Number database is linked to the new Database where the
form is stored.

Upon selecting the number in Column 0 - say 12345 - in the after update I
wish the corresponding table in the Purchase Order Database to have a check
(Tick) added in the control called 'NAF" in the row corresponding to the PO
number 12345.

So far this is all my brain will allow me to think

Private Sub OrderRef_AfterUpdate()


Dim strFilter As String
'Evaluate filter before it is passed to Dlookup function
strFilter = "[OrderNumbers]= " & [OrderRef].Column(0)
'Update PO Table NAF control based on PO value selected in the combo box
Nz (DLookup("[NAF]", "[OrderNumbers]", strFilter))

rem OrdeNumbers.NAF = true

End Sub


How do I link the dlookup which finds the correct row and then check the
control - make it true?

Thanks in advance
 
C

Clifford Bass

Hi Bill,

You could use the RunSQL method:

DoCmd.SetWarnings False
DoCmd.RunSQL _
"update OrderNumbers " & _
"set NAF = True " & _
"where PurchaseOrderNumber = " & OrderRef.Column(0)
DoCmdSetWarnings True

Clifford Bass
 
D

Douglas J. Steele

<picky>
It's easier to use the Execute method:

CurrentDb.Execute _
"update OrderNumbers " & _
"set NAF = True " & _
"where PurchaseOrderNumber = " & OrderRef.Column(0), _
dbFailOnError

It saves having to set the warnings off and back on, plus it'll cause a
trappable error to be raised if something goes wrong with the query.
</picky>

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Clifford Bass said:
Hi Bill,

You could use the RunSQL method:

DoCmd.SetWarnings False
DoCmd.RunSQL _
"update OrderNumbers " & _
"set NAF = True " & _
"where PurchaseOrderNumber = " & OrderRef.Column(0)
DoCmdSetWarnings True

Clifford Bass

Bill said:
Hi,

On a form is a combobox which selects a Purchase order number.

The Purchase order Number database is linked to the new Database where
the
form is stored.

Upon selecting the number in Column 0 - say 12345 - in the after update
I
wish the corresponding table in the Purchase Order Database to have a
check
(Tick) added in the control called 'NAF" in the row corresponding to the
PO
number 12345.

So far this is all my brain will allow me to think

Private Sub OrderRef_AfterUpdate()


Dim strFilter As String
'Evaluate filter before it is passed to Dlookup function
strFilter = "[OrderNumbers]= " & [OrderRef].Column(0)
'Update PO Table NAF control based on PO value selected in the combo box
Nz (DLookup("[NAF]", "[OrderNumbers]", strFilter))

rem OrdeNumbers.NAF = true

End Sub


How do I link the dlookup which finds the correct row and then check the
control - make it true?

Thanks in advance
 
B

Bill

Excellent Thankyou Thankyou Thankyou to both.
Much appreciated

Best regards
Bill

Douglas J. Steele said:
<picky>
It's easier to use the Execute method:

CurrentDb.Execute _
"update OrderNumbers " & _
"set NAF = True " & _
"where PurchaseOrderNumber = " & OrderRef.Column(0), _
dbFailOnError

It saves having to set the warnings off and back on, plus it'll cause a
trappable error to be raised if something goes wrong with the query.
</picky>

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Clifford Bass said:
Hi Bill,

You could use the RunSQL method:

DoCmd.SetWarnings False
DoCmd.RunSQL _
"update OrderNumbers " & _
"set NAF = True " & _
"where PurchaseOrderNumber = " & OrderRef.Column(0)
DoCmdSetWarnings True

Clifford Bass

Bill said:
Hi,

On a form is a combobox which selects a Purchase order number.

The Purchase order Number database is linked to the new Database where
the
form is stored.

Upon selecting the number in Column 0 - say 12345 - in the after update
I
wish the corresponding table in the Purchase Order Database to have a
check
(Tick) added in the control called 'NAF" in the row corresponding to the
PO
number 12345.

So far this is all my brain will allow me to think

Private Sub OrderRef_AfterUpdate()


Dim strFilter As String
'Evaluate filter before it is passed to Dlookup function
strFilter = "[OrderNumbers]= " & [OrderRef].Column(0)
'Update PO Table NAF control based on PO value selected in the combo box
Nz (DLookup("[NAF]", "[OrderNumbers]", strFilter))

rem OrdeNumbers.NAF = true

End Sub


How do I link the dlookup which finds the correct row and then check the
control - make it true?

Thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top