?
Solved

Recordsource Macros

Posted on 2003-02-25
4
Medium Priority
?
218 Views
Last Modified: 2010-05-01
Hi, I'm just a beginner so this is probably a v.straightforward question sorry...!
I'm using VB to link to an Access db, I want to run a Macro by clicking on a command button. I've linked up the db using the Properties window, the Recordsource tab gives me an option to link a certain table but I want to link directly to the macro is this possible.....?
Do I still need to declare the connection in the code itself as well as connecting it in the properties window??
I hope this makes sense to somebody....

0
Comment
Question by:coppertop
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:dmang
ID: 8018025
You can declare and manage everything in code
0
 

Author Comment

by:coppertop
ID: 8024113
This is the Code I'm trying to use, can you give me any ideas as to what the problem is....??  The error I'm getting is
"The Microsoft Jet database Engine cannot find the input table or query 'Update Tables'. Make sure it exists and that its name is spelled correctly."


Private Sub UpdateTables_Click()

MsgBox "Update Tables?", vbYesNo + vbExclamation, "Confirm Update"

If No Then GoTo UpdateTables_Err

Else

Set AccessApp = New Access.Application

With AccessApp
    .OpenCurrentDatabase App.Path & "\\Fs1\9831363u\FYP\Class Lists etc.mdb"
Data1.RecordSource = "UpdateTables"

    ' Update 1st Year ID nos.
    DoCmd.OpenQuery "update", acNormal, acEdit
    ' Update 2nd Year ID nos.
    DoCmd.OpenQuery "update2", acNormal, acEdit
    ' Update 3rd Year ID nos.
    DoCmd.OpenQuery "update3", acNormal, acEdit
    ' Update 4th Year ID nos.
    DoCmd.OpenQuery "update4", acNormal, acEdit
    ' Insert 4th Year Class into Alumni
    DoCmd.OpenQuery "InsertAlumni", acNormal, acEdit
    ' Insert 3rd Year Class into 4th Year
    DoCmd.OpenQuery "Insert4th", acNormal, acEdit
    ' Insert 2nd Year Class into 3rd Year
    DoCmd.OpenQuery "Insert3rd", acNormal, acEdit
    ' Insert 1st Year Class into 2nd Year
    DoCmd.OpenQuery "Insert2nd", acNormal, acEdit
    ' Leave 1st Year Table blank for new students
    DoCmd.OpenQuery "delete1st", acNormal, acEdit

UpdateTables_Exit:
    Exit Sub
     
UpdateTables_Err:
    MsgBox Error$
    Resume UpdateTables_Exit

End With

End Sub

Any help would be gratefully accepted...! Thanks.
0
 
LVL 9

Accepted Solution

by:
dmang earned 150 total points
ID: 8025010
Looks like your database doe not contain a table object named "Update Tables"
0
 

Author Comment

by:coppertop
ID: 8025207
I got it sorted since using much simpler code, thanks for your help
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question