On click button command

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have three fields 1)"Loaned" a logical field 2) "Person Loaned To" a text
field 3) "Date Loaned" a date field

I have a button that when clicked I want to change the "Loaned" from a
logical "No" to a "Yes"

and have a pop up window asking for the name of the person I loaned the book
to and when I enter the name and click "OK" it puts that name in the "Person
Loaned To" field

and automatically puts today's date in the "Date Loaned" field.

HELP!!!
 
You need code in the OnClick event of your button:

Private Sub YourButtonName_Click()
Me.Loaned = True
Me.Person_Loaned_To = InputBox("Enter Name:")
Me.Date_Loaned = Date
End Sub

BTW, you'll make life lots easier for yourself if you don't include spaces
in field names.

HTH,

Rob

"(e-mail address removed)"
 
On Fri, 8 Dec 2006 20:26:00 -0800,
I have three fields 1)"Loaned" a logical field 2) "Person Loaned To" a text
field 3) "Date Loaned" a date field

I have a button that when clicked I want to change the "Loaned" from a
logical "No" to a "Yes"

and have a pop up window asking for the name of the person I loaned the book
to and when I enter the name and click "OK" it puts that name in the "Person
Loaned To" field

and automatically puts today's date in the "Date Loaned" field.

HELP!!!

Why go through so many contortions?
No need to have a pop-up at all.
Just enter a name directly in the [PersonLoanedTo] field.

Code the [PersonLoanedTo] control's AfterUpdate event:
If Not IsNull([PersonLoanedTo]) Then
Me![Loaned] = -1
Me![DateLoaned] = Date
Else
Me![Loaned] = 0
Me![DateLoaned] = Null
End If

And you could most probably do without the [Loaned] field completely.
If there is a name in the PersonLoanedTo field, then it is Loaned. No
name and it's not loaned.
 
Thank you, I'll try this.


fredg said:
On Fri, 8 Dec 2006 20:26:00 -0800,
I have three fields 1)"Loaned" a logical field 2) "Person Loaned To" a text
field 3) "Date Loaned" a date field

I have a button that when clicked I want to change the "Loaned" from a
logical "No" to a "Yes"

and have a pop up window asking for the name of the person I loaned the book
to and when I enter the name and click "OK" it puts that name in the "Person
Loaned To" field

and automatically puts today's date in the "Date Loaned" field.

HELP!!!

Why go through so many contortions?
No need to have a pop-up at all.
Just enter a name directly in the [PersonLoanedTo] field.

Code the [PersonLoanedTo] control's AfterUpdate event:
If Not IsNull([PersonLoanedTo]) Then
Me![Loaned] = -1
Me![DateLoaned] = Date
Else
Me![Loaned] = 0
Me![DateLoaned] = Null
End If

And you could most probably do without the [Loaned] field completely.
If there is a name in the PersonLoanedTo field, then it is Loaned. No
name and it's not loaned.
 

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

Back
Top