473,411 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Forms![variable]! ??

36
Hi again,

I would like to learn how to make this work
With a click of a button I copy and rename a table and form from templates
the problem is that I want relink the new form to the new table (instead of being linked to the template)

Access keeps telling me that NewName! form does not exist. Its taking the name literally instead of its value. Could anyone help

Private Sub Command6_Click()
NewName = Username.Value

DoCmd.CopyObject , NewName, acTable, "template"
DoCmd.CopyObject , NewName, acForm, "template"

Forms!NewName!ID.ControlSource = [NewName]![ID]
Nov 26 '06 #1
10 1656
Killer42
8,435 Expert 8TB
Is NewName a variant? Perhaps it would make a difference if it were a string.
Nov 26 '06 #2
Killer42
8,435 Expert 8TB
Also, in this line of code
Expand|Select|Wrap|Line Numbers
  1. Forms!NewName!ID.ControlSource = [NewName]![ID]
I think (pretty rusty on this) that you can replace Forms!NewName with Forms(NewName)
Nov 26 '06 #3
NeoPa
32,556 Expert Mod 16PB
Also, in this line of code
Expand|Select|Wrap|Line Numbers
  1. Forms!NewName!ID.ControlSource = [NewName]![ID]
I think (pretty rusty on this) that you can replace Forms!NewName with Forms(NewName)
Not only can you, but you must.
the Collection! format requires the actual name to be used. As you only have a variable containing the name, you can only use the Collection() format to refer to it.
Nov 26 '06 #4
omozali
36
Is NewName a variant? Perhaps it would make a difference if it were a string.

NewName is a value taken from a input box. its supposed to represent a newuser who is being created with the end result of having his own table and form
Nov 26 '06 #5
omozali
36
I tried several methods of writing this but I can't seem to access the field ID using
forms()

I tried forms(NewName)!ID.Controlsource, forms(NewName!ID.Controlsource)

Trying this forms(NewName.ID).ControlSource would bring on my code window but without telling me whats the error
Nov 26 '06 #6
Killer42
8,435 Expert 8TB
I tried several methods of writing this but I can't seem to access the field ID using forms()
I tried forms(NewName)!ID.Controlsource, forms(NewName!ID.Controlsource)
Have you tried this variation?
Expand|Select|Wrap|Line Numbers
  1. forms(NewName).ID.Controlsource
(I underlined the difference).
Nov 26 '06 #7
PEB
1,418 Expert 1GB
Have you tried this variation?
Expand|Select|Wrap|Line Numbers
  1. forms(NewName).ID.Controlsource
(I underlined the difference).
I think trhis may provoke an error

try also

Expand|Select|Wrap|Line Numbers
  1. forms(NewName).("ID").Controlsource
  2.  
Nov 26 '06 #8
omozali
36
Have you tried this variation?
Expand|Select|Wrap|Line Numbers
  1. forms(NewName).ID.Controlsource
(I underlined the difference).
Once I type forms(NewName). <- [with the dot] then a list of options show up which indicate different properties of the form and non indicate a away to access a field. Ocfourse going ahead and continuing typing as ID.Controlsource will produce error.

I feel frustrated

I wish I could find somesort of reference to every and (I mean every) function, command, and other things that does not seem to be written any where
Nov 26 '06 #9
Killer42
8,435 Expert 8TB
Once I type forms(NewName). <- [with the dot] then a list of options show up which indicate different properties of the form and non indicate a away to access a field. Of course going ahead and continuing typing as ID.Controlsource will produce error.
I wouldn't be too sure of that - it might be worth a try.

I think this comes down to the old issue of late- versus early-binding. In this case, VB cannot provide the control names in the list of attributes for the form, because it won't know until runtime which form it is. All it can check is the general syntax of the statement. At runtime, it will have to verify that the control you referred to actually exists.

Also, is there a Controls property in the list? If so, you might try something like
Expand|Select|Wrap|Line Numbers
  1. forms(NewName).Controls("ID").ControlSource
I feel frustrated
Welcome to programming. :)

I wish I could find somesort of reference to every and (I mean every) function, command, and other things that does not seem to be written any where
I'm pretty sure it is all reasonably well documented, but can be difficult to find sometimes.
Nov 26 '06 #10
NeoPa
32,556 Expert Mod 16PB
Killer's absolutely right on this.
Try typing it anyway.
The list it prompts you with is NOT necessarily the full list!
Nov 26 '06 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: ALthePal | last post by:
Hi, I'm not sure if we are able to or even how to loop through the web forms in a VB.NET project during design time. In MSAccess we are able to go through the database -> forms collection and...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
3
by: Joshua Russell | last post by:
Hi, Both the methods below open up a windows form called MasterForm. However, one works better than the other. Method 1 opens the form correctly but I don't have any reference to the instance of...
7
by: Mike Bulava | last post by:
I have created a base form that I plan to use throughout my application let call the form form1. I have Built the project then add another form that inherits from form1, I add a few panel controls...
13
by: MD | last post by:
I have been converting a program from VB6 to VB.Net and enhancing it as well. All has been progressing OK although its been hard work. Now, all of a sudden, when I try to execute a ShowDialog()...
15
by: Joshua Kendall | last post by:
I have a script in which it keeps opening the same form instead of only one instance. I also need help with a form that has a password. Where do I put the actual password? can I use a database for...
3
by: Lloyd Sheen | last post by:
I have the following situation: Need a user resizable user control. After much trying with user control I came across the idea of hosting the controls in a form marked as not TopLevel = false. ...
8
by: Stephen Rice | last post by:
Hi, I have a periodic problem which I am having a real time trying to sort. Background: An MDI VB app with a DB on SQL 2000. I have wrapped all the DB access into an object which spawns a...
3
by: Geraldine Hobley | last post by:
Hello, In my project I am inheriting several forms. However when I inherit from a form and add additional subroutines and methods to my inherited form I get all sorts of problems. e.g. I sometimes...
6
by: dbuchanan | last post by:
I have a Windows Forms application that accesses SQL Server 2k from a small local network. The application has been used for weeks on other systmes but a new install on a new machine retruns...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.