coding problem

G

Guest

is it possible to write code so that when you press a button on a form it
ticks a box and adds a date to a query

i came up with this: -

Private Sub Invoice_Click()
On Error GoTo Err_Command51_Click

Dim stDocName As String

stDocName = "Due to be invoced"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_Command51_Click:
Exit Sub



Me.[Invoice Raised] = 1
Me.[Invoice Date] = Date

Exit_Welcome_Letter_Click:
Exit Sub
Err_Command51_Click:
MsgBox Err.Description
Resume Exit_Command51_Click

End Sub

it runs and displays the query but does nothing with the tick box and date
fields, i am not very good at coding and may have made a mistake

Thanks

Phil
 
R

Ruskin Hardie

You almost have it correct, but you have an 'Exit Sub' before the setting of
the 'Invoice Raised' and 'Invoice Date' fields. You may want to move the
setting of the invoice raised and date fields, to before the
Err_Command51_Click line.
 
R

Ruskin Hardie

Sorry, meant to say, move the invoice raised and date fields to before the
EXIT_Command51_Click line...

Ruskin Hardie said:
You almost have it correct, but you have an 'Exit Sub' before the setting of
the 'Invoice Raised' and 'Invoice Date' fields. You may want to move the
setting of the invoice raised and date fields, to before the
Err_Command51_Click line.


Phil said:
is it possible to write code so that when you press a button on a form it
ticks a box and adds a date to a query

i came up with this: -

Private Sub Invoice_Click()
On Error GoTo Err_Command51_Click

Dim stDocName As String

stDocName = "Due to be invoced"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_Command51_Click:
Exit Sub



Me.[Invoice Raised] = 1
Me.[Invoice Date] = Date

Exit_Welcome_Letter_Click:
Exit Sub
Err_Command51_Click:
MsgBox Err.Description
Resume Exit_Command51_Click

End Sub

it runs and displays the query but does nothing with the tick box and date
fields, i am not very good at coding and may have made a mistake

Thanks

Phil
 
G

Guest

thanks for your reply. that only changes the current record in the form
that i press the button from is there anyway to change all the records that
match the query criteria

thanks

Phil

Ruskin Hardie said:
Sorry, meant to say, move the invoice raised and date fields to before the
EXIT_Command51_Click line...

Ruskin Hardie said:
You almost have it correct, but you have an 'Exit Sub' before the setting of
the 'Invoice Raised' and 'Invoice Date' fields. You may want to move the
setting of the invoice raised and date fields, to before the
Err_Command51_Click line.


Phil said:
is it possible to write code so that when you press a button on a form it
ticks a box and adds a date to a query

i came up with this: -

Private Sub Invoice_Click()
On Error GoTo Err_Command51_Click

Dim stDocName As String

stDocName = "Due to be invoced"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_Command51_Click:
Exit Sub



Me.[Invoice Raised] = 1
Me.[Invoice Date] = Date

Exit_Welcome_Letter_Click:
Exit Sub
Err_Command51_Click:
MsgBox Err.Description
Resume Exit_Command51_Click

End Sub

it runs and displays the query but does nothing with the tick box and date
fields, i am not very good at coding and may have made a mistake

Thanks

Phil
 

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

Similar Threads


Top