Error : Name? (1 Viewer)

kostaskir

Registered User.
Local time
Today, 20:30
Joined
Jan 21, 2009
Messages
65
Hello everybody ,

I have one table with 3 fields. The table also has only one row.

I want to display to an Edit Box in a form the second field and I get the error: Name?.

Do you know what does it means?

Example:
Field A, Field B, Field C
Row A 100 200 300

I want to display field B in an edit box. That all and I get the above error message. This Table will have only one row in the future.



Thank you in advance. :)
 

John Big Booty

AWF VIP
Local time
Tomorrow, 03:30
Joined
Aug 29, 2005
Messages
8,263
Is the form bound to the table? i.e. Does the Form have the Table as it's Record Source?

If you have said Yes to both those questions then the Control Source for your Text Box should simply be the Name of Field B.

Please also be aware that unlike Excel, Access does not name rows so you can not reference a Row (Record) in the way you have done in your example.
 
Last edited:

MStef

Registered User.
Local time
Today, 18:30
Joined
Oct 28, 2004
Messages
2,251
It means that you made a mistake somewhere.
Send a short example of your mdb. (access 2000, 2002).
 

kostaskir

Registered User.
Local time
Today, 20:30
Joined
Jan 21, 2009
Messages
65
I use Access 97 (unfortunately...)

In the properties window, in the Tab "Data" I can see only Record Source.

I wrote : =[XML_Vehicle]![Baumuster]

XML_Vehicle: Table
Baumuster: Field.



Is the form bound to the table? i.e. Does the Form have the Table as it's Record Source?

According your first question : AI would like to clarify that I intend to use data in the same form from different Tables & Queries. So I guess I can't do that. Am I right or not ?
 

Attachments

  • Error.jpg
    Error.jpg
    92.8 KB · Views: 62

vbaInet

AWF VIP
Local time
Today, 18:30
Joined
Jan 22, 2010
Messages
26,374
You refer to fields within your form or subform. XML_Vehicle is a table. Maybe you want to use a combo box and set the row source of that combo box to that table.
 

MStef

Registered User.
Local time
Today, 18:30
Joined
Oct 28, 2004
Messages
2,251
Try next; In the Control Source put:

=DLookup("[Baumaster]","XML_Vehicle")
 

vbaInet

AWF VIP
Local time
Today, 18:30
Joined
Jan 22, 2010
Messages
26,374
I thought about that but I didn't want to advise using a DLookup because that could slow things down as this would mean calling the DLookup for everytime you move through records. It should be using sparingly, not persistently.
 

kostaskir

Registered User.
Local time
Today, 20:30
Joined
Jan 21, 2009
Messages
65
The DLookup it doesn't work. I don't know why...

I tried Combo and List Boxes and it works fine.
But is not suitable. Because later on I want to do some calculations. Discounts etc...

And this is my actual problem, the calculations. I really need your help guys.
 

vbaInet

AWF VIP
Local time
Today, 18:30
Joined
Jan 22, 2010
Messages
26,374
MStef gave you an example of the DLookup("1st_Argument", "2nd_Argument", "3rd_Argument"), he was hoping you would look it up in the help files? You need the third argument for it to work (if you want to follow that route).

Maybe you should explain what you want to achieve with this?
 

kostaskir

Registered User.
Local time
Today, 20:30
Joined
Jan 21, 2009
Messages
65
If you have any proposition with VBA I am all ears :)

I want to do it with text boxes because I have a range o fields with Vehicle Prices that I want to calculate.

Example:

Vehicle A:
Net Price: 100 $
Vat: 19 $
Total: 119 $
---------------

Then the customer want some extras:

Extra A (Net Price): 10 $
Extra A (Vat): 2 $
Total: 12 $

Vehicle A:(With Extras)
Net Price: 110
Vat: 31$


TOTAL: 141 $.

And I think that with text boxes is the best way to do that.
What do you think ?
 

vbaInet

AWF VIP
Local time
Today, 18:30
Joined
Jan 22, 2010
Messages
26,374
So the VAT is a value you enter or it's a value derived from a fixed percentage of the Net Price?

From your setup since you want to show a Net Price and VAT for the extra, both VAT text boxes could be deriving their values from the same source.

Where does [Baumuster] fit into these calculations you have explained?
 

kostaskir

Registered User.
Local time
Today, 20:30
Joined
Jan 21, 2009
Messages
65
I found it guys !

I added an extra field in my table: Constant with default value: 1

and then in my form i did this :

Code:
Private Sub Form_Load()


Dim con As Integer, varX As Variant
con = 1
varX = DLookup("[Baumuster]", "XML_Vehicle", "[[B]Constant[/B]] = " & con)
    
    Baumuster.Value = varX
     

End Sub
So the condition is:

Show me the value of the field Baumuster when the value of the field Constant is 1.

Thank you for your support.

;)
 

vbaInet

AWF VIP
Local time
Today, 18:30
Joined
Jan 22, 2010
Messages
26,374
Excellent.

If that what you wanted was to get the value when the form loads (and not on current record) and the con value would remain 1 then you can cut down your code to this:

Baumuster.Value = DLookup("[Baumuster]", "XML_Vehicle", "[Constant] = 1")
Also, rename your "Constant" field to something else. It may be a reserved keyword and may lead to conflicts. Even if it doesn't, you could easily confuse it for constant variables which is normally written as Const.
 

Users who are viewing this thread

Top Bottom