Changing a value before you open a new form

bloody_football

Registered User.
Local time
Today, 14:28
Joined
Sep 8, 2004
Messages
70
I am in my quotes form and I have a button which converts the quote into a sale, the button also opens a new form with the sale information.

A) Before the new form opens I wish to change a value in the old form (to say that the quote has in fact been changed into a sale), the code I have is
Code:
DoCmd.RunSQL "INSERT INTO Quotes (ConvertToHire) VALUES (-1)"
but this adds another record into the quotes database (with no information) and does not change the current record.

B) What is the code I need to have a label appear on a form if a certain condition is met - if the quote has been converted to a sale then I wish for a note to appear to say this; that way someone doesn't try to convert it again.
 
A) You can use the OnClick event of your button which opens your new form to change the value of your field.

e.g. On you click event you can put something as follows:

Me.YourFieldname = "Sale"


B) you can create a label and play with its visibility.

Code:
If condition = true then
me.labelname.visible = true
else
me.labelname.visible = false
end if
 
Thanks for the reply Max, i'll try it and see what happens :)
 
I have used Max's code (with great success) for visibilty, just need to ask if anyone knows how to turn the visibility off for a button after it has been pushed.
I have tried the simple method of turning the visibility off in the button code but I get the error 'Can't turn off visibilty on an item that has focus' (not excact wording), is there another method of doing this?
 
Solution for button to go invisible when/after it is clicked. See db example. The first part is to make the button invisible and an independent label visible. The second part makes the button visible and the label invisible. (That by clicking on the label). It works because in both click events of the two parts described above, the focus is first sent to a textbox.

Code:
Private Sub cmdVisible_Click()
    DoCmd.GoToControl "txtBoxFirst"
    Me.cmdVisible.Visible = False
    Me.lblClick.Visible = True
End Sub

Private Sub lblClick_Click()
    DoCmd.GoToControl "txtBoxFirst"
    Me.lblClick.Visible = False
    Me.cmdVisible.Visible = True
End Sub
 

Attachments

Last edited:

Users who are viewing this thread

Back
Top Bottom