I just can't figure it out! (1 Viewer)

faesce

Registered User.
Local time
Yesterday, 23:41
Joined
Feb 16, 2012
Messages
22
I'm sorta new with access when it comes to the programming side of things. From the user side though I'm familiar, so I know what I need done, but am unsure as to how to do it.

Basically what I have is a barcode system setup that when somebody mails a donation to us, I can scan the code and it brings their record up. What I'd like, in order to automate the process, is to create a simple button that fills in the amount sent in (it is 9 times out of 10 the same as the amount requested; this dollar amount is already input on another box in the record, basically need this copied to the "amount paid" box on click of button), as well as the current date needs to be added into a separate Date box. The final thing is we have a checkbox for "collected" that needs to be checked with this button.

How could I go about filling out these two boxes and checking my checkbox with a single button press? This way all we need to do is scan the scanner which brings up the record, then click the button to fill the forms, and move right into the next one.

Any help would be greatly appreciated.
 

vbaInet

AWF VIP
Local time
Today, 06:41
Joined
Jan 22, 2010
Messages
26,374
For copying between controls, you just need to refer to the control and set the value of the other control from right to left.
Code:
ControlToBeSet = ControlWithValue
Here's a website re referencing controls:
http://access.mvps.org/access/forms/frm0031.htm

For the date part, use Date() on the right hand side of the equal to sign (as shown above). Or if it's going to happen for new records only, set the Default Value property of the field to Date().

For checkboxes, -1 represents checked and 0 represents not checked.
 

faesce

Registered User.
Local time
Yesterday, 23:41
Joined
Feb 16, 2012
Messages
22
Awesome, thank you much. I'll do some reading and see if I can get it working. Now, is it possible to set the focus on a certain box after that checkbox gets checked? That way it has the right box selected ready for the next scan.
 

vbaInet

AWF VIP
Local time
Today, 06:41
Joined
Jan 22, 2010
Messages
26,374
Yes it is. You would use the SetFocus method of the control to move focus to the control. This code will go in the Click event or After Update event of the checkbox. E.g.:
Code:
Me.ControlName.SetFocus
Where ControlName is the name of the control you would like to move the focus to.
 

faesce

Registered User.
Local time
Yesterday, 23:41
Joined
Feb 16, 2012
Messages
22
Alright. I've got it to do what I want. It copies the amount, adds in the date, checks the box, and puts the cursor where I want it. However there's a strange side effect!

The info is being put into the correct boxes and everything, except it doesn't display until after a refresh! i.e. I have to either close the record and re-open it and then it will display in the box, OR I have to click on the box and then it shows up. It seems like the data is in fact going to the right place, its just a display bug? Is there a trick to force it to display instantly when I click my button?

Here's my code:

Private Sub Command94_Click()
tblPledgesLead!PledgeAmountRecd = tblPledgesLead!Custom1
tblPledgesLead!DateRecd = Date
tblPledgesLead!Collected = -1
Me.txtSelectPhone.SetFocus
End Sub
 

faesce

Registered User.
Local time
Yesterday, 23:41
Joined
Feb 16, 2012
Messages
22
Bump. Any idea on how I could get this to show up right away?
 

tinyevil777

Registered User.
Local time
Today, 06:41
Joined
Dec 10, 2010
Messages
137
You need to add a "Me.Requery [MyControlName]" for any fields you want to refresh (display the updated data)
 

faesce

Registered User.
Local time
Yesterday, 23:41
Joined
Feb 16, 2012
Messages
22
You need to add a "Me.Requery [MyControlName]" for any fields you want to refresh (display the updated data)

Hm. This doesn't seem to work. This gives me an invalid arguments error.
 

faesce

Registered User.
Local time
Yesterday, 23:41
Joined
Feb 16, 2012
Messages
22
Try:
Me.NameOfYourControl.Requery

What I'm wanting refreshed is both tblPledgesLead!PledgeAmountRecd and tblPledgesLead!DateRecd.

So if I'm understanding correctly, I should have

Me.tblPledgesLead!PledgeAmountRecd.Requery
Me.tblPledgesLead!DateRecd.Requery

This gives a runtime error 438:
Object doesn't support this property or method.
 

bob fitz

AWF VIP
Local time
Today, 06:41
Joined
May 23, 2011
Messages
4,717
Me.tblPledgesLead!PledgeAmountRecd.Requery
Me.tblPledgesLead!DateRecd.Requery
The bit in red needs to be the name of the control. You can see what that is by looking at the controls "Name" property.
My guess would be that you need:
Me.PledgeAmountRecd.Requery
Me.DateRecd.Requery
 

faesce

Registered User.
Local time
Yesterday, 23:41
Joined
Feb 16, 2012
Messages
22
When I use:

Me.PledgeAmountRecd.Requery
Me.DateRecd.Requery

I get:

Compile error:
Method or data member not found


EDIT:

I got it! What was happening was when I went and viewed the property sheet, the Name was actually different than the Source Object. The person who created this database had PledgeAmountRecd for the source object named as PledgeAmountRec'd and the apostrophe was throwing it off. Same thing for my date field. Now it auto refreshes without needing to requery at all! This is absolutely perfect now!

Hopefully changing the name won't have any adverse effects on anything else.

Thank you all very much, you've been life savers!
 
Last edited:

bob fitz

AWF VIP
Local time
Today, 06:41
Joined
May 23, 2011
Messages
4,717
Can you attach a copy of the db in A2003 mdb format.
Please remove any sensitive data first.
 

Users who are viewing this thread

Top Bottom