Amend Coded Command Buttons using code?

Mikeyboi92

Registered User.
Local time
Today, 18:52
Joined
Aug 1, 2013
Messages
10
Right this is the 3rd time ive typed this and then the stupid design of the keyboard makes me go back a page and all is lost!!! :eek::mad:

I want to be able to change certain parts of a Query and Code based on the contets of a text box.

Example with Command Button Code:

Textbox contains the name Tom

This is a command button on a form that i have copied and renamed etc through VBA to Tom (contents in the textbox)

DoCmd.RunCommand acCmdSaveRecord
DoCmd.SetWarnings (False)
DoCmd.OpenQuery "Qry BM to Management", acViewNormal
DoCmd.SetWarnings (True)
DoCmd.GoToRecord , , acNext

I now want to change where it says "Qry BM to Management" to "Qry Tom to Management",


Example with Command Query:

Again Textbox Contains Tom

Query has been copied but now i want to change the following SQL string from where it says Bhavins Table to Toms Table

INSERT INTO [Management Table] (Postcode)
SELECT [Bhavins Table].Postcode
FROM [Bhavins Table];



Im not sure if this is possible but i would like to know as adding a new user to my Database takes me about 10-15 minutes but I know what im doing (copy paste change specific parts of Queires and points of forms etc ) but i need to make it easy for management to add new Users....

Thanks for any advise on this.... because right now i feel like im doing this :banghead:
 
Hi Pr2-eugin,

Thanks for the reply!

I have looked at these and thats is something i can do but i wondered if there is away in which i can Copy an existing Query (as the queries are the same but the Table names are different) then replace the table names with the Text box Value? as the QueryDefs is from what i saw a way of creating a completly new query from Scratch or am i wrong in this?


Also what would you suggest regarding The VBA Coding for the command Buton ?
 

Users who are viewing this thread

Back
Top Bottom