Can you see what's wrong with this CODE? (1 Viewer)

davepino

New member
Local time
Today, 12:07
Joined
Dec 4, 2018
Messages
6
This string of code is riddled with errors, however I used it in my other database and it worked fine (only my field names were different).

All I'm trying to do is have a checkbox populate a field by grabbing the data from the field next to it. I keep getting Compile Error Messages.

I've been trying to figure this out for 6 hours now. I'm not a student of MS ACCESS, so I feel like I'm breaking a very basic rule. Any help will be mega appreciated! Thanks.


Private Sub chkSwitch_Click()
If Me.14T-PAID-APT1 = True Then
Me.14TaylorApt-1 = Me.PopulatedRent1
End If
End Sub


Private Sub 14T_PAID_APT1_Click()
If Me.14T-PAID-APT1 = True Then
Me.14TaylorApt-1 = Me.PopulatedRent1
End If
If Me.14T-PAID-APT1 = False Then
Me.14TaylorApt-1 = 0
End If
End Sub
 

Minty

AWF VIP
Local time
Today, 20:07
Joined
Jul 26, 2013
Messages
10,371
Make sure at the very top of the code window it saye the following;
Code:
Option Compare Database
Option Explicit

I suspect your control names are incorrect. By putting the Option Explicit in all your code modules it will highlight naming errors when you try and compile the code.

In the VBA code window press Debug¬Compile and it will step through your code highlighting any errors it finds, If you get stuck with that then post back here with the code and the highlighted line and the error message.
 

isladogs

MVP / VIP
Local time
Today, 20:07
Joined
Jan 14, 2017
Messages
18,217
In addition control names should only contain letters or numbers and if you wish underscores.
Using - is likely to cause problems in recent versions of Access (older versions were more forgiving)

Is that a control name Me.14TaylorApt-1 or Me.14TaylorApt minus 1

Either replace - with _ .... or place those control names in []. For example

Code:
Private Sub chkSwitch_Click()
If Me.[14T-PAID-APT1] = True Then
    Me.[14TaylorApt-1] = Me.PopulatedRent1
End If
End Sub


Private Sub 14T_PAID_APT1_Click()
If Me.[14T-PAID-APT1] = True Then
   Me.[14TaylorApt-1] = Me.PopulatedRent1
[COLOR="Green"]'End If 'remove
'If Me.[14T-PAID-APT1] = False Then 'remove [/COLOR]
Else [COLOR="SeaGreen"]'add[/COLOR]
   Me.[14TaylorApt-1] = 0
End If
End Sub

Note the use of Else to simplify your code

EDIT:
I moved this thread to Modules & VBA as it is a technical question
Welcome to the forum as well
 
Last edited:

davepino

New member
Local time
Today, 12:07
Joined
Dec 4, 2018
Messages
6
What a wonderful feeling to wake up to a response!
I tried what you all suggested but it is still not working. I decided to start from scratch and send screen shots with notes.

I got rid of any and all spaces in the names. I did this in the tables.
I double check in the field names as well to make sure no spaces were there either.

Attached is a pic of what I'm trying to do.
I also attached a photo of something I noticed. In the drop-down box of the coding window, I see the old titles are still there. Could that also be causing my problem?

Thanks for your help. I can't tell you how comforting it feels. I didn't go to school for this and I have ZERO friends that do MS ACCESS programming.

(NOTE: since this is only my second post here I can't submit photos so I provided link addresses instead )

12taylor.com/wp-content/uploads/2018/12/HELPmakeWork.jpg

12taylor.com/wp-content/uploads/2018/12/old-names.jpg
 

isladogs

MVP / VIP
Local time
Today, 20:07
Joined
Jan 14, 2017
Messages
18,217
LOL
If you spend too long using Access, you could end up with ZERO friends - FULL STOP!

New users can attach files if they are zipped.
Please could you put both images into a zip file & upload
 

davepino

New member
Local time
Today, 12:07
Joined
Dec 4, 2018
Messages
6
HaHa, No Way , I'm making friends right now!

I think I attached the Zip.
 

Attachments

  • Access ScreenShots.zip
    131.7 KB · Views: 65

davepino

New member
Local time
Today, 12:07
Joined
Dec 4, 2018
Messages
6
I definitely do spend a lot of time on ACCESS. But it's to save time down the road with paper work and record searching. Right? If I do have a cut off time. 2 weeks max. Also, I think this is a great program to learn.
 

davepino

New member
Local time
Today, 12:07
Joined
Dec 4, 2018
Messages
6
GREAT NEWS EVERYONE. I figured out my problem. It was a case of disorder with my field names.
1. I started over with my table
2. Got rid of complicated names with space and numbers
3. Made sure all my field names in the "Properties" sheet were accurate to my codes.
4. I did what everyone here suggested.

Now it works. What a feeling!!

Thanks.
 

isladogs

MVP / VIP
Local time
Today, 20:07
Joined
Jan 14, 2017
Messages
18,217
Glad you found the solution.
Did you mean 2 weeks max to learn Access? If so you're a very quick learner.
I've been using it for almost 20 years and I'm still learning new things
 

davepino

New member
Local time
Today, 12:07
Joined
Dec 4, 2018
Messages
6
Hi, 2 weeks is my goal to finish this project I'm working on. I started learning MS ACCESS in 2008 (self taught). I built an automated accounting system for my brothers business. He was scratching his head for hours every night trying to figure out the math and missing money. I learned his company and with ACCESS got him down to 15 minutes a day of data entry to keep track of every penny as well as auto-reverse-engineer mistakes his employees make.

I built another one for my friends music school. Since we're all musicians we're flaky with money so the book i built him kept track of hours, money, tips, percentages ect. with basic data entry everyday.

Now it's my parents turn with the real estate they've amassed. They're foreigners with little computer literacy, so what I built has to be easy enough for a monkey to use. It has to keep track of who pays rent when, as well as get them inside of their utilities and taxes profiles on-line easily. I'm trying to make it as easy as possible to keep track of leases, bills, and notices for mailing.

They're doing everything as if it's 1954 still. I see them spend HOURS with paper work (mostly looking for it). I also see them dealing with phone calls all the time, so I've built a form to text message system for an ($80 a month) call answering service to handle that comes with simple drop down menus and general instructions for the operator. We'll receive messages via texts with Alert Levels of importance, and clickable links for easy responses if we choose to respond.

I've looked into software and management companies and they all sound too expensive and complicated for their taste. Real Estate is not rocket science, but some of these real estate management softwares would require training. With a well thought out system and automation I'm hoping to make this SUPER easy, and reduce their work load, and improve accuracy. It's also to reduce my headaches. My phone rings non-stop sometimes and it's hard to focus on other ventures or jobs. It's a lot of units for a family of 4.

Thank you a ton for communicating with me on this. I will be back with more questions if I can't break through my next hurdle.

I've built 3 forms that accesses 3 tables. This constitutes 1 multi family building. Now I'm trying to make clones of the Forms and Tables (20 times) hoping for them to communicate only with their respective selves. so far the cloning process is not going as I'd hoped, but I'm sure there is a way. I don't want to have to build the forms and tables for each building. That will take me more than 2 weeks. :-/

If you have any tips I'm all ears! I hope you have a pleasant day!

Cheers!
 

isladogs

MVP / VIP
Local time
Today, 20:07
Joined
Jan 14, 2017
Messages
18,217
Certainly seems a worthwhile use of Access.

One way to save time would be to create a template form with all the controls and code that you will need to reuse repeatedly. Save that as e.g frmTemplate.
Then when you need a new form, make a copy of that as your starting point and build on that.
 

JHB

Have been here a while
Local time
Today, 21:07
Joined
Jun 17, 2012
Messages
7,732
..Now I'm trying to make clones of the Forms and Tables (20 times) hoping for them to communicate only with their respective selves....
Do you say that you'll have a table and form for each building?
 

Minty

AWF VIP
Local time
Today, 20:07
Joined
Jul 26, 2013
Messages
10,371
@JHB and OP - Yes he did !
I don't want to have to build the forms and tables for each building. That will take me more than 2 weeks. :-/

This sounds like a fundamental design no no.

You should have one set of tables and a unique building identifier that ties back to a table containing the building ID and the top level building details.
 

isladogs

MVP / VIP
Local time
Today, 20:07
Joined
Jan 14, 2017
Messages
18,217
Perhaps that'll teach me to answer before breakfast!

Not sure how I managed to overlook that point.
I agree completely that is the wrong approach

For clarity, the template form idea was to replicate standard items like form design/layout together with buttons such as Print, Close.
 

Users who are viewing this thread

Top Bottom