Records not adding...Please help!

Y

Yula

I have read thru all the posts and I can't figure out what I am doing wrong.
I am not at all an expert in Access and everything I have done so far was
based on help I received while posting here. I finally figured out how to
make one combo box base on another, I have come to a complete halt with this
form. I can't add records, the whole point of this project. I looked at all
the properties and everything is enabled. I copied the SQL into a new query
and there I was able to add records. I am sure, than it’s something with the
form. I just don't have enough knowledge to figure out how to fix this.

Could it be that I have a lot of combo boxes based on queries??

I greatly appreciate any help I could get!
Yula
 
M

Maurice

Why not show us the sql statement? It might be that your comboboxes are bound
while they should be unbound because the come from different tables...
 
Y

Yula

Thank you for responding: Below is the SQL for the form... Again, it almost
seems that the recordsource for the form is in no way tied to the selections
in the controls.

SELECT Main_Table.Inserter, Main_Table.Date, Main_Table.Meter,
Main_Table.Shift, Main_Table.Category, Main_Table.Job, Main_Table.ID,
Main_Table.Count, Main_Table.Postage, Main_Table.MasterItem1,
Main_Table.PSItem1, Main_Table.Description1, Main_Table.Price1,
Main_Table.MasterItem2, Main_Table.PSItem2, Main_Table.Description2,
Main_Table.Price2, Main_Table.CostCenter, Main_Table.Contact, Main_Table.OH,
Main_Table.Post, Main_Table.Total
FROM Main_Table;
 
M

Maurice

Yula,

The SQL-statement looks straight forward. Have you created a standard form
and changed nothing. In that case you should be able to enter data. Is there
a subform on the form? If you look in design of the form look at the
properties of the form to see if the allow additions property is set to yes.
I assume there's no code behind the form what could be 'bugging' your form?
 
Y

Yula

I created a standard form and than I added a lot of combo boxes and text
boxes that are based on queries. Also, below is the forms after update
procedure. I have combo boxes based on one another.

I think the problem is that the form needs some kind of a procedure to save
to the recordsource table. I think there is a diconnect between the controls
being selected on the form and the table where I want them to be saved. I am
just not sure what to do about it. Should I create a procedure to save
afterupdate to the table which is my recordsource



Private Sub Category_AfterUpdate()
Me.Job = Null
Me.Job.Requery
Me.Job = Me.Job.ItemData(0)
End Sub







Private Sub JES_AfterUpdate()
Me.JES = Null
Me.JES.Requery
Me.JES = Me.JES.ItemData(0)
End Sub


Private Sub Form_Current()
If Me.NewRecord Then
Me!Inserter.SetFocus
End If


End Sub

Private Sub ID_AfterUpdate()

End Sub

Private Sub ID_BeforeUpdate(Cancel As Integer)

End Sub

Private Sub Job_AfterUpdate()
Me.ID = Null
Me.ID.Requery
Me.ID = Me.ID.ItemData(0)
End Sub


Private Sub Command230_Click()
On Error GoTo Err_Command230_Click


DoCmd.GoToRecord , , acNext

Exit_Command230_Click:
Exit Sub

Err_Command230_Click:
MsgBox Err.Description
Resume Exit_Command230_Click

End Sub
Private Sub Command231_Click()
On Error GoTo Err_Command231_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_Command231_Click:
Exit Sub

Err_Command231_Click:
MsgBox Err.Description
Resume Exit_Command231_Click

End Sub
 
B

BruceM

Are the combo boxes and text boxes that are based on queries bound to fields
in the form's record source query?
Saving the record After Update will not do anything I can see, since
updating means the record has been saved. You would be saving it after it
has been saved. However, if you wish to force a save during record creation
(for instance, if there is validation code in Before Update you may wish to
force the Before Update event to run) you can just use Me.Dirty = False
instead of that MenuItem stuff.
Are you able to compile the code?
 
Y

Yula

Below are my combo boxes:

Combo Category = Row Source = Select Query
Combo Job = Row Source = Query 5 (Main Query)

Cat ID, Cat code, Job Name, Master item, PS item, Master Desc, Price, Master
item 2, ps item2, price2, mat2, job cc, contact

Combo ID = row source = query 5, event procedure after update

text box = count

postage = row source = select query postage

tab 2 - materials

control source = Master Item = Forms!FrmJob1!ID.Column(3)
Control Source=PS Item = " " (4)
Control Source = Desc = " " (5)
Control Source = Price = " " (6)

control source = Master Item2 = Forms!FrmJob1!ID.Column(7)
Control Source=PS Item 2= " " (8)
Control Source = Desc 2= " " (10)
Control Source = Price 2= " " (9)

Summary
Control Source Material A = forms!FrmJob1ID.Column(6)*Forms!frmjob1!count
Control Source Material b = forms!FrmJob1ID.Column(9)*Forms!frmjob1!count
Control Source OH = Forms!frmjob1!count*.1234
Control Source Postage = Forms!frmjob1!count*Forms!FrmJob1!Postage.column1(1)

I need the user to fill in the info and all the info needs to be saved to a
new table. Bruce, I am not sure what you mean by compile the code? Do you
mean run? everything works when I click out of design view. I just can't add
any records or save it anywhere.
 
B

BruceM

With the VBA editor open, click Debug > Compile ___ to compile the code. If
you have created a situation such as attempting to requery a field (rather
than a control), it will highlight the line of code. It also guards against
typographical errors, and quite a few other things that will prevent the
code from running.
I am not quite sure what to make of something like:
control source = Master Item2 = Forms!FrmJob1!ID.Column(7)
Is MasterItem2 a combo box? If so, Forms!FrmJob1!ID.Column(7) cannot be its
control source. The Control Source is the field to which a control is
bound. If you have a Contacts table with fields for FirstName, LastName,
etc., and you create a form bound to the Contacts table for entering and
editing contact information, then information typed into a text box with its
control source set to FirstName will store that information in the FirstName
field of the Contacts table.
To elaborate a bit, open a form in design view. Click View > Properties (or
double click the small square at the very top left of the form window). You
will see a place for the Record Source. If you select a table or a query
bound to the table as the Record Source, the form is a bound form. That is,
it is bound to that record source (table or query). The form becomes a sort
of portal to the table.
Next, the controls. A control is a combo box, text box, label, line, or
just about anything else on the form. Some controls, such as text boxes and
combo boxes, may be bound to fields in the form's Record Source. That is, a
field from the form's Record Source is selected as the control's Control
Source. Information entered into the bound control (or selected from a
combo box list, which accomplishes the same thing as typing into a text box)
will be stored in that field in the form's Record Source.
Back to the code you have provided, this cannot do anything I can see:
Control Source=PS Item 2= " " (8)
Another thing I found puzzling was that you said the info needs to be saved
to a new table. Why? It is possible to create a table through code and
store information there. I couldn't say exactly how to go about that, but I
doubt very much that it is what you need to do.
I think a greater understanding of some of the terminology would be of help.
A good place to start is here:
http://allenbrowne.com/tips.html
In particular, look at the Table Design links in the Tips for Casual Users.
On the right side of the page, toward the bottom of the list, is a Links
link. That will take you to quite an extensive list of Access links for
users of all levels.
 
Y

Yula

Bruce thank you for all your advise so far, but here is the problem. I have
been working on this project for a while and I really need to come up with a
form for people to fill out that will store the info that they fill in. I
don't have the luxury any more to learn more termanology, I have to show
something for all the time I out in. I leaned access from scratch and the
posts that i found here... and I am sure I know maybe 3% of what's there, but
that's not excuse for not getting this project done.

To answer your questions: I ran the compile in VBA and there was one
problem, I took care of it. When I say Control source = master Item
#=forms!FrmJob1ID.Column(7), I mean by that the control source in the
properties sheet for that text box is called master item #.

Also, I don't think I would need a "contact" table to be updated b/c the
user is selecting from a given list of operators. When they select the
operator from the combo box, other text boxes are automatically populated.

Ex. Combo box Operator. Row souce in properties is called operator query
Column 1 shows: Bob, John, Joe, Mike

Machine they work on text box: autopopulates 12345 (based on Operator query
column 2)

Shift they work, text box autopopulates 1 (based on operator query column 3)

That's pretty much the set up for this form. When the user selects something
from the combo box(based on row sources and the text boxes based on control
sources), other text boxes autopopulate. I hope this makes sense.
 
B

BruceM

Responses inline.

Yula said:
Bruce thank you for all your advise so far, but here is the problem. I
have
been working on this project for a while and I really need to come up with
a
form for people to fill out that will store the info that they fill in. I
don't have the luxury any more to learn more termanology, I have to show
something for all the time I out in. I leaned access from scratch and the
posts that i found here... and I am sure I know maybe 3% of what's there,
but
that's not excuse for not getting this project done.

A great deal can be accomplished with just a fraction of the capabilities of
Access, but a solid design is essential to using Access properly. Without
knowing more about how your database is structured or the real-world
situation it is trying to addess I may not be able to offer many useful
suggestions. Much can be accomplished with Access, but there is a
substantial learning curve. You may not have enough knowledge of the
product to get the particular job done. By analogy, having a learner's
permit, and being familiar with the basics of putting a car into gear and
steering it around the neighborhood, does not qualify you to take part in a
road rally. It's not an excuse, it's a fact.
To answer your questions: I ran the compile in VBA and there was one
problem, I took care of it. When I say Control source = master Item
#=forms!FrmJob1ID.Column(7), I mean by that the control source in the
properties sheet for that text box is called master item #.

For what text box? What is Forms!frmJob1ID.Column(7)?
Also, I don't think I would need a "contact" table to be updated b/c the
user is selecting from a given list of operators. When they select the
operator from the combo box, other text boxes are automatically populated.

The Contacts table was an example: "If you have a Contacts table ...". It
is a familiar situation, so I had hoped it would be useful as an example.
Ex. Combo box Operator. Row souce in properties is called operator query
Column 1 shows: Bob, John, Joe, Mike

What is the source for the operator query? Is there an Employee table or
something of the sort?
Machine they work on text box: autopopulates 12345 (based on Operator
query
column 2)

Each operator works on just one machine? Do you mean they operate the
machine, or is this a shop that repairs machines? "Work on" is a vague
term. In any case, "machine they work on" is not an attribute of an
operator, so the information should be stored in a separate table. If that
is already the case, and the operator query assembles information from
several tables, the question remains whether you need to store the
information about machine and shift, or just link to it.
Shift they work, text box autopopulates 1 (based on operator query column
3)

That's pretty much the set up for this form. When the user selects
something
from the combo box(based on row sources and the text boxes based on
control
sources), other text boxes autopopulate. I hope this makes sense.

I'm sorry to have to tell you it does not make much sense to me. I am
unfamiliar either with the real-world business situation you are trying to
address or the structure of your database. If you can post a description of
the tables and relationships it may be possible to come up with something
more definite.
 
Y

Yula

Bruce, thanks for your advise! The scope of the project changesd direction a
bit. I have another questions, maybe you can help me. I am trying to create
this IIF statement in a control and something is off, can you take a look at
it?


= IIf( [2oz] ="X" and [Date] <0#5/14/2007#,.545,IIf( [2oz] = is Null and
[Date] <#5/14/2007#,.321,IIf( [2oz] = "x" and [Date] >=#05/14/2007#,.459,IIf(
[2oz] = is Null and [Date] >= #05/14/2007#,.334))))


THANK YOU!
 
B

BruceM

It is ususally a good idea to state the nature of the problem. "Something
is off" is vague.

I noticed a few things. There was an extra 0 before the first instance of
the Date. Also, use Is Null, not = Is Null. Be aware that Date is a
reserved word in Access, and should not be used for a field name. For a
listing of reserved words, see:
http://www.accessmvp.com/JConrad/accessjunkie/resources.html#ReservedWords
In particular, look at Reserved Words in Microsoft Access and Reserved Words
in Jet 4.0.
You can get around using a reserved word by enclosing it in brackets, but
sooner or later you will run into a problem with using reserved words
incorrectly, and it could be difficult to track down.
Having said that, here is your expression, amended.

= IIf( [2oz] ="X" and [Date] < #5/14/2007#,.545,IIf( [2oz] Is Null and
[Date] < #5/14/2007#,.321,IIf( [2oz] = "x" and [Date] >=
#05/14/2007#,.459,IIf(
[2oz] Is Null and [Date] >= #05/14/2007#,.334))))

You can, however, shorten it to something like:
= IIf([2oz] = "X",IIf([Date] < #5/14/07#,.545,.459),IIf([2oz] Is
Null,IIf([Date] < #5/14/07#,.321,.334)))

There are only two choices for the date: before 5/14/07, or else on or after
5/14/07. You don't need to test for >=, because anything that is not < is
automatically >=. If the only two choices are X or null, you can shorten it
to:
= IIf([2oz] = "X",IIf([Date] < #5/14/07#,.545,.459),IIf([Date] <
#5/14/07#,.321,.334))
However, if there could be an entry other than X or Null you will need to
allow for that in the expression:

= IIf([2oz] = "X",IIf([Date] < #5/14/07#,.545,.459),IIf([2oz] Is
Null,IIf([Date] < #5/14/07#,.321,.334),"Other"))

If the expression gets much more involved than that you may do well to use
VBA, where a wider range of approaches are possible.

Yula said:
Bruce, thanks for your advise! The scope of the project changesd direction
a
bit. I have another questions, maybe you can help me. I am trying to
create
this IIF statement in a control and something is off, can you take a look
at
it?


= IIf( [2oz] ="X" and [Date] <0#5/14/2007#,.545,IIf( [2oz] = is Null and
[Date] <#5/14/2007#,.321,IIf( [2oz] = "x" and [Date]
=#05/14/2007#,.459,IIf(
[2oz] = is Null and [Date] >= #05/14/2007#,.334))))


THANK YOU!

BruceM said:
Responses inline.



A great deal can be accomplished with just a fraction of the capabilities
of
Access, but a solid design is essential to using Access properly.
Without
knowing more about how your database is structured or the real-world
situation it is trying to addess I may not be able to offer many useful
suggestions. Much can be accomplished with Access, but there is a
substantial learning curve. You may not have enough knowledge of the
product to get the particular job done. By analogy, having a learner's
permit, and being familiar with the basics of putting a car into gear and
steering it around the neighborhood, does not qualify you to take part in
a
road rally. It's not an excuse, it's a fact.


For what text box? What is Forms!frmJob1ID.Column(7)?

The Contacts table was an example: "If you have a Contacts table ...".
It
is a familiar situation, so I had hoped it would be useful as an example.


What is the source for the operator query? Is there an Employee table or
something of the sort?


Each operator works on just one machine? Do you mean they operate the
machine, or is this a shop that repairs machines? "Work on" is a vague
term. In any case, "machine they work on" is not an attribute of an
operator, so the information should be stored in a separate table. If
that
is already the case, and the operator query assembles information from
several tables, the question remains whether you need to store the
information about machine and shift, or just link to it.


I'm sorry to have to tell you it does not make much sense to me. I am
unfamiliar either with the real-world business situation you are trying
to
address or the structure of your database. If you can post a description
of
the tables and relationships it may be possible to come up with something
more definite.
 
Y

Yula

Bruce, Thank you very much, this was very helpful!!!

BruceM said:
It is ususally a good idea to state the nature of the problem. "Something
is off" is vague.

I noticed a few things. There was an extra 0 before the first instance of
the Date. Also, use Is Null, not = Is Null. Be aware that Date is a
reserved word in Access, and should not be used for a field name. For a
listing of reserved words, see:
http://www.accessmvp.com/JConrad/accessjunkie/resources.html#ReservedWords
In particular, look at Reserved Words in Microsoft Access and Reserved Words
in Jet 4.0.
You can get around using a reserved word by enclosing it in brackets, but
sooner or later you will run into a problem with using reserved words
incorrectly, and it could be difficult to track down.
Having said that, here is your expression, amended.

= IIf( [2oz] ="X" and [Date] < #5/14/2007#,.545,IIf( [2oz] Is Null and
[Date] < #5/14/2007#,.321,IIf( [2oz] = "x" and [Date] >=
#05/14/2007#,.459,IIf(
[2oz] Is Null and [Date] >= #05/14/2007#,.334))))

You can, however, shorten it to something like:
= IIf([2oz] = "X",IIf([Date] < #5/14/07#,.545,.459),IIf([2oz] Is
Null,IIf([Date] < #5/14/07#,.321,.334)))

There are only two choices for the date: before 5/14/07, or else on or after
5/14/07. You don't need to test for >=, because anything that is not < is
automatically >=. If the only two choices are X or null, you can shorten it
to:
= IIf([2oz] = "X",IIf([Date] < #5/14/07#,.545,.459),IIf([Date] <
#5/14/07#,.321,.334))
However, if there could be an entry other than X or Null you will need to
allow for that in the expression:

= IIf([2oz] = "X",IIf([Date] < #5/14/07#,.545,.459),IIf([2oz] Is
Null,IIf([Date] < #5/14/07#,.321,.334),"Other"))

If the expression gets much more involved than that you may do well to use
VBA, where a wider range of approaches are possible.

Yula said:
Bruce, thanks for your advise! The scope of the project changesd direction
a
bit. I have another questions, maybe you can help me. I am trying to
create
this IIF statement in a control and something is off, can you take a look
at
it?


= IIf( [2oz] ="X" and [Date] <0#5/14/2007#,.545,IIf( [2oz] = is Null and
[Date] <#5/14/2007#,.321,IIf( [2oz] = "x" and [Date]
=#05/14/2007#,.459,IIf(
[2oz] = is Null and [Date] >= #05/14/2007#,.334))))


THANK YOU!

BruceM said:
Responses inline.

Bruce thank you for all your advise so far, but here is the problem. I
have
been working on this project for a while and I really need to come up
with
a
form for people to fill out that will store the info that they fill in.
I
don't have the luxury any more to learn more termanology, I have to
show
something for all the time I out in. I leaned access from scratch and
the
posts that i found here... and I am sure I know maybe 3% of what's
there,
but
that's not excuse for not getting this project done.

A great deal can be accomplished with just a fraction of the capabilities
of
Access, but a solid design is essential to using Access properly.
Without
knowing more about how your database is structured or the real-world
situation it is trying to addess I may not be able to offer many useful
suggestions. Much can be accomplished with Access, but there is a
substantial learning curve. You may not have enough knowledge of the
product to get the particular job done. By analogy, having a learner's
permit, and being familiar with the basics of putting a car into gear and
steering it around the neighborhood, does not qualify you to take part in
a
road rally. It's not an excuse, it's a fact.


To answer your questions: I ran the compile in VBA and there was one
problem, I took care of it. When I say Control source = master Item
#=forms!FrmJob1ID.Column(7), I mean by that the control source in the
properties sheet for that text box is called master item #.

For what text box? What is Forms!frmJob1ID.Column(7)?

Also, I don't think I would need a "contact" table to be updated b/c
the
user is selecting from a given list of operators. When they select the
operator from the combo box, other text boxes are automatically
populated.

The Contacts table was an example: "If you have a Contacts table ...".
It
is a familiar situation, so I had hoped it would be useful as an example.


Ex. Combo box Operator. Row souce in properties is called operator
query
Column 1 shows: Bob, John, Joe, Mike

What is the source for the operator query? Is there an Employee table or
something of the sort?


Machine they work on text box: autopopulates 12345 (based on Operator
query
column 2)

Each operator works on just one machine? Do you mean they operate the
machine, or is this a shop that repairs machines? "Work on" is a vague
term. In any case, "machine they work on" is not an attribute of an
operator, so the information should be stored in a separate table. If
that
is already the case, and the operator query assembles information from
several tables, the question remains whether you need to store the
information about machine and shift, or just link to it.


Shift they work, text box autopopulates 1 (based on operator query
column
3)

That's pretty much the set up for this form. When the user selects
something
from the combo box(based on row sources and the text boxes based on
control
sources), other text boxes autopopulate. I hope this makes sense.

I'm sorry to have to tell you it does not make much sense to me. I am
unfamiliar either with the real-world business situation you are trying
to
address or the structure of your database. If you can post a description
of
the tables and relationships it may be possible to come up with something
more definite.

:

With the VBA editor open, click Debug > Compile ___ to compile the
code.
If
you have created a situation such as attempting to requery a field
(rather
than a control), it will highlight the line of code. It also guards
against
typographical errors, and quite a few other things that will prevent
the
code from running.
I am not quite sure what to make of something like:
control source = Master Item2 = Forms!FrmJob1!ID.Column(7)
Is MasterItem2 a combo box? If so, Forms!FrmJob1!ID.Column(7) cannot
be
its
control source. The Control Source is the field to which a control is
bound. If you have a Contacts table with fields for FirstName,
LastName,
etc., and you create a form bound to the Contacts table for entering
and
editing contact information, then information typed into a text box
with
its
control source set to FirstName will store that information in the
FirstName
field of the Contacts table.
To elaborate a bit, open a form in design view. Click View >
Properties
(or
double click the small square at the very top left of the form
window).
You
will see a place for the Record Source. If you select a table or a
query
bound to the table as the Record Source, the form is a bound form.
That
is,
it is bound to that record source (table or query). The form becomes
a
sort
of portal to the table.
Next, the controls. A control is a combo box, text box, label, line,
or
just about anything else on the form. Some controls, such as text
boxes
and
combo boxes, may be bound to fields in the form's Record Source. That
is, a
field from the form's Record Source is selected as the control's
Control
Source. Information entered into the bound control (or selected from
a
combo box list, which accomplishes the same thing as typing into a
text
box)
will be stored in that field in the form's Record Source.
Back to the code you have provided, this cannot do anything I can see:
Control Source=PS Item 2= " " (8)
Another thing I found puzzling was that you said the info needs to be
saved
to a new table. Why? It is possible to create a table through code
and
store information there. I couldn't say exactly how to go about that,
but I
doubt very much that it is what you need to do.
I think a greater understanding of some of the terminology would be of
help.
A good place to start is here:
http://allenbrowne.com/tips.html
In particular, look at the Table Design links in the Tips for Casual
Users.
On the right side of the page, toward the bottom of the list, is a
Links
link. That will take you to quite an extensive list of Access links
for
users of all levels.

Below are my combo boxes:

Combo Category = Row Source = Select Query
Combo Job = Row Source = Query 5 (Main Query)

Cat ID, Cat code, Job Name, Master item, PS item, Master Desc,
Price,
Master
item 2, ps item2, price2, mat2, job cc, contact

Combo ID = row source = query 5, event procedure after update

text box = count

postage = row source = select query postage

tab 2 - materials

control source = Master Item = Forms!FrmJob1!ID.Column(3)
Control Source=PS Item = " " (4)
Control Source = Desc = " " (5)
Control Source = Price = " " (6)

control source = Master Item2 = Forms!FrmJob1!ID.Column(7)
Control Source=PS Item 2= " " (8)
Control Source = Desc 2= " " (10)
Control Source = Price 2= " " (9)

Summary
Control Source Material A =
forms!FrmJob1ID.Column(6)*Forms!frmjob1!count
Control Source Material b =
forms!FrmJob1ID.Column(9)*Forms!frmjob1!count
Control Source OH = Forms!frmjob1!count*.1234
Control Source Postage =
Forms!frmjob1!count*Forms!FrmJob1!Postage.column1(1)

I need the user to fill in the info and all the info needs to be
saved
to
a
new table. Bruce, I am not sure what you mean by compile the code?
Do
you
mean run? everything works when I click out of design view. I just
can't
add
any records or save it anywhere.

:

Are the combo boxes and text boxes that are based on queries bound
to
fields
in the form's record source query?
Saving the record After Update will not do anything I can see,
since
updating means the record has been saved. You would be saving it
after
it
has been saved. However, if you wish to force a save during record
creation
(for instance, if there is validation code in Before Update you may
wish
to
force the Before Update event to run) you can just use Me.Dirty =
 
B

BruceM

Glad to help. Good luck with the project.

Yula said:
Bruce, Thank you very much, this was very helpful!!!

BruceM said:
It is ususally a good idea to state the nature of the problem.
"Something
is off" is vague.

I noticed a few things. There was an extra 0 before the first instance
of
the Date. Also, use Is Null, not = Is Null. Be aware that Date is a
reserved word in Access, and should not be used for a field name. For a
listing of reserved words, see:
http://www.accessmvp.com/JConrad/accessjunkie/resources.html#ReservedWords
In particular, look at Reserved Words in Microsoft Access and Reserved
Words
in Jet 4.0.
You can get around using a reserved word by enclosing it in brackets, but
sooner or later you will run into a problem with using reserved words
incorrectly, and it could be difficult to track down.
Having said that, here is your expression, amended.

= IIf( [2oz] ="X" and [Date] < #5/14/2007#,.545,IIf( [2oz] Is Null and
[Date] < #5/14/2007#,.321,IIf( [2oz] = "x" and [Date] >=
#05/14/2007#,.459,IIf(
[2oz] Is Null and [Date] >= #05/14/2007#,.334))))

You can, however, shorten it to something like:
= IIf([2oz] = "X",IIf([Date] < #5/14/07#,.545,.459),IIf([2oz] Is
Null,IIf([Date] < #5/14/07#,.321,.334)))

There are only two choices for the date: before 5/14/07, or else on or
after
5/14/07. You don't need to test for >=, because anything that is not <
is
automatically >=. If the only two choices are X or null, you can shorten
it
to:
= IIf([2oz] = "X",IIf([Date] < #5/14/07#,.545,.459),IIf([Date] <
#5/14/07#,.321,.334))
However, if there could be an entry other than X or Null you will need to
allow for that in the expression:

= IIf([2oz] = "X",IIf([Date] < #5/14/07#,.545,.459),IIf([2oz] Is
Null,IIf([Date] < #5/14/07#,.321,.334),"Other"))

If the expression gets much more involved than that you may do well to
use
VBA, where a wider range of approaches are possible.

Yula said:
Bruce, thanks for your advise! The scope of the project changesd
direction
a
bit. I have another questions, maybe you can help me. I am trying to
create
this IIF statement in a control and something is off, can you take a
look
at
it?


= IIf( [2oz] ="X" and [Date] <0#5/14/2007#,.545,IIf( [2oz] = is Null
and
[Date] <#5/14/2007#,.321,IIf( [2oz] = "x" and [Date]
=#05/14/2007#,.459,IIf(
[2oz] = is Null and [Date] >= #05/14/2007#,.334))))


THANK YOU!

:

Responses inline.

Bruce thank you for all your advise so far, but here is the problem.
I
have
been working on this project for a while and I really need to come
up
with
a
form for people to fill out that will store the info that they fill
in.
I
don't have the luxury any more to learn more termanology, I have to
show
something for all the time I out in. I leaned access from scratch
and
the
posts that i found here... and I am sure I know maybe 3% of what's
there,
but
that's not excuse for not getting this project done.

A great deal can be accomplished with just a fraction of the
capabilities
of
Access, but a solid design is essential to using Access properly.
Without
knowing more about how your database is structured or the real-world
situation it is trying to addess I may not be able to offer many
useful
suggestions. Much can be accomplished with Access, but there is a
substantial learning curve. You may not have enough knowledge of the
product to get the particular job done. By analogy, having a
learner's
permit, and being familiar with the basics of putting a car into gear
and
steering it around the neighborhood, does not qualify you to take part
in
a
road rally. It's not an excuse, it's a fact.


To answer your questions: I ran the compile in VBA and there was one
problem, I took care of it. When I say Control source = master Item
#=forms!FrmJob1ID.Column(7), I mean by that the control source in
the
properties sheet for that text box is called master item #.

For what text box? What is Forms!frmJob1ID.Column(7)?

Also, I don't think I would need a "contact" table to be updated b/c
the
user is selecting from a given list of operators. When they select
the
operator from the combo box, other text boxes are automatically
populated.

The Contacts table was an example: "If you have a Contacts table
...".
It
is a familiar situation, so I had hoped it would be useful as an
example.


Ex. Combo box Operator. Row souce in properties is called operator
query
Column 1 shows: Bob, John, Joe, Mike

What is the source for the operator query? Is there an Employee table
or
something of the sort?


Machine they work on text box: autopopulates 12345 (based on
Operator
query
column 2)

Each operator works on just one machine? Do you mean they operate the
machine, or is this a shop that repairs machines? "Work on" is a
vague
term. In any case, "machine they work on" is not an attribute of an
operator, so the information should be stored in a separate table. If
that
is already the case, and the operator query assembles information from
several tables, the question remains whether you need to store the
information about machine and shift, or just link to it.


Shift they work, text box autopopulates 1 (based on operator query
column
3)

That's pretty much the set up for this form. When the user selects
something
from the combo box(based on row sources and the text boxes based on
control
sources), other text boxes autopopulate. I hope this makes sense.

I'm sorry to have to tell you it does not make much sense to me. I am
unfamiliar either with the real-world business situation you are
trying
to
address or the structure of your database. If you can post a
description
of
the tables and relationships it may be possible to come up with
something
more definite.

:

With the VBA editor open, click Debug > Compile ___ to compile the
code.
If
you have created a situation such as attempting to requery a field
(rather
than a control), it will highlight the line of code. It also
guards
against
typographical errors, and quite a few other things that will
prevent
the
code from running.
I am not quite sure what to make of something like:
control source = Master Item2 = Forms!FrmJob1!ID.Column(7)
Is MasterItem2 a combo box? If so, Forms!FrmJob1!ID.Column(7)
cannot
be
its
control source. The Control Source is the field to which a control
is
bound. If you have a Contacts table with fields for FirstName,
LastName,
etc., and you create a form bound to the Contacts table for
entering
and
editing contact information, then information typed into a text box
with
its
control source set to FirstName will store that information in the
FirstName
field of the Contacts table.
To elaborate a bit, open a form in design view. Click View >
Properties
(or
double click the small square at the very top left of the form
window).
You
will see a place for the Record Source. If you select a table or a
query
bound to the table as the Record Source, the form is a bound form.
That
is,
it is bound to that record source (table or query). The form
becomes
a
sort
of portal to the table.
Next, the controls. A control is a combo box, text box, label,
line,
or
just about anything else on the form. Some controls, such as text
boxes
and
combo boxes, may be bound to fields in the form's Record Source.
That
is, a
field from the form's Record Source is selected as the control's
Control
Source. Information entered into the bound control (or selected
from
a
combo box list, which accomplishes the same thing as typing into a
text
box)
will be stored in that field in the form's Record Source.
Back to the code you have provided, this cannot do anything I can
see:
Control Source=PS Item 2= " " (8)
Another thing I found puzzling was that you said the info needs to
be
saved
to a new table. Why? It is possible to create a table through
code
and
store information there. I couldn't say exactly how to go about
that,
but I
doubt very much that it is what you need to do.
I think a greater understanding of some of the terminology would be
of
help.
A good place to start is here:
http://allenbrowne.com/tips.html
In particular, look at the Table Design links in the Tips for
Casual
Users.
On the right side of the page, toward the bottom of the list, is a
Links
link. That will take you to quite an extensive list of Access
links
for
users of all levels.

Below are my combo boxes:

Combo Category = Row Source = Select Query
Combo Job = Row Source = Query 5 (Main Query)

Cat ID, Cat code, Job Name, Master item, PS item, Master Desc,
Price,
Master
item 2, ps item2, price2, mat2, job cc, contact

Combo ID = row source = query 5, event procedure after update

text box = count

postage = row source = select query postage

tab 2 - materials

control source = Master Item = Forms!FrmJob1!ID.Column(3)
Control Source=PS Item = " " (4)
Control Source = Desc = " " (5)
Control Source = Price = " " (6)

control source = Master Item2 = Forms!FrmJob1!ID.Column(7)
Control Source=PS Item 2= " " (8)
Control Source = Desc 2= " " (10)
Control Source = Price 2= " " (9)

Summary
Control Source Material A =
forms!FrmJob1ID.Column(6)*Forms!frmjob1!count
Control Source Material b =
forms!FrmJob1ID.Column(9)*Forms!frmjob1!count
Control Source OH = Forms!frmjob1!count*.1234
Control Source Postage =
Forms!frmjob1!count*Forms!FrmJob1!Postage.column1(1)

I need the user to fill in the info and all the info needs to be
saved
to
a
new table. Bruce, I am not sure what you mean by compile the
code?
Do
you
mean run? everything works when I click out of design view. I
just
can't
add
any records or save it anywhere.

:

Are the combo boxes and text boxes that are based on queries
bound
to
fields
in the form's record source query?
Saving the record After Update will not do anything I can see,
since
updating means the record has been saved. You would be saving
it
after
it
has been saved. However, if you wish to force a save during
record
creation
(for instance, if there is validation code in Before Update you
may
wish
to
force the Before Update event to run) you can just use Me.Dirty
=
 
Y

Yula

Bruce, Thanks Again. I am finished with the form part of the project, but now
I have to make a report based on the info in the form. I am having trouble
adding calculated controls from the form into the report.
Ex. My calculated control in a form takes the mailed pieces * cost of
material 1. Next control takes mailed pieces * cost of material 2

Material 1 control is named: MaterialA
Material 2 control is named: MaterialB

I want to take the value from that control and put it into a report that has
a label
materials and below it there is a calculated control called
forms![form1][MaterialA]+
forms![form1][MaterialB]

IS this possible??



BruceM said:
Glad to help. Good luck with the project.

Yula said:
Bruce, Thank you very much, this was very helpful!!!

BruceM said:
It is ususally a good idea to state the nature of the problem.
"Something
is off" is vague.

I noticed a few things. There was an extra 0 before the first instance
of
the Date. Also, use Is Null, not = Is Null. Be aware that Date is a
reserved word in Access, and should not be used for a field name. For a
listing of reserved words, see:
http://www.accessmvp.com/JConrad/accessjunkie/resources.html#ReservedWords
In particular, look at Reserved Words in Microsoft Access and Reserved
Words
in Jet 4.0.
You can get around using a reserved word by enclosing it in brackets, but
sooner or later you will run into a problem with using reserved words
incorrectly, and it could be difficult to track down.
Having said that, here is your expression, amended.

= IIf( [2oz] ="X" and [Date] < #5/14/2007#,.545,IIf( [2oz] Is Null and
[Date] < #5/14/2007#,.321,IIf( [2oz] = "x" and [Date] >=
#05/14/2007#,.459,IIf(
[2oz] Is Null and [Date] >= #05/14/2007#,.334))))

You can, however, shorten it to something like:
= IIf([2oz] = "X",IIf([Date] < #5/14/07#,.545,.459),IIf([2oz] Is
Null,IIf([Date] < #5/14/07#,.321,.334)))

There are only two choices for the date: before 5/14/07, or else on or
after
5/14/07. You don't need to test for >=, because anything that is not <
is
automatically >=. If the only two choices are X or null, you can shorten
it
to:
= IIf([2oz] = "X",IIf([Date] < #5/14/07#,.545,.459),IIf([Date] <
#5/14/07#,.321,.334))
However, if there could be an entry other than X or Null you will need to
allow for that in the expression:

= IIf([2oz] = "X",IIf([Date] < #5/14/07#,.545,.459),IIf([2oz] Is
Null,IIf([Date] < #5/14/07#,.321,.334),"Other"))

If the expression gets much more involved than that you may do well to
use
VBA, where a wider range of approaches are possible.

Bruce, thanks for your advise! The scope of the project changesd
direction
a
bit. I have another questions, maybe you can help me. I am trying to
create
this IIF statement in a control and something is off, can you take a
look
at
it?


= IIf( [2oz] ="X" and [Date] <0#5/14/2007#,.545,IIf( [2oz] = is Null
and
[Date] <#5/14/2007#,.321,IIf( [2oz] = "x" and [Date]
=#05/14/2007#,.459,IIf(
[2oz] = is Null and [Date] >= #05/14/2007#,.334))))


THANK YOU!

:

Responses inline.

Bruce thank you for all your advise so far, but here is the problem.
I
have
been working on this project for a while and I really need to come
up
with
a
form for people to fill out that will store the info that they fill
in.
I
don't have the luxury any more to learn more termanology, I have to
show
something for all the time I out in. I leaned access from scratch
and
the
posts that i found here... and I am sure I know maybe 3% of what's
there,
but
that's not excuse for not getting this project done.

A great deal can be accomplished with just a fraction of the
capabilities
of
Access, but a solid design is essential to using Access properly.
Without
knowing more about how your database is structured or the real-world
situation it is trying to addess I may not be able to offer many
useful
suggestions. Much can be accomplished with Access, but there is a
substantial learning curve. You may not have enough knowledge of the
product to get the particular job done. By analogy, having a
learner's
permit, and being familiar with the basics of putting a car into gear
and
steering it around the neighborhood, does not qualify you to take part
in
a
road rally. It's not an excuse, it's a fact.


To answer your questions: I ran the compile in VBA and there was one
problem, I took care of it. When I say Control source = master Item
#=forms!FrmJob1ID.Column(7), I mean by that the control source in
the
properties sheet for that text box is called master item #.

For what text box? What is Forms!frmJob1ID.Column(7)?

Also, I don't think I would need a "contact" table to be updated b/c
the
user is selecting from a given list of operators. When they select
the
operator from the combo box, other text boxes are automatically
populated.

The Contacts table was an example: "If you have a Contacts table
...".
It
is a familiar situation, so I had hoped it would be useful as an
example.


Ex. Combo box Operator. Row souce in properties is called operator
query
Column 1 shows: Bob, John, Joe, Mike

What is the source for the operator query? Is there an Employee table
or
something of the sort?


Machine they work on text box: autopopulates 12345 (based on
Operator
query
column 2)

Each operator works on just one machine? Do you mean they operate the
machine, or is this a shop that repairs machines? "Work on" is a
vague
term. In any case, "machine they work on" is not an attribute of an
operator, so the information should be stored in a separate table. If
that
is already the case, and the operator query assembles information from
several tables, the question remains whether you need to store the
information about machine and shift, or just link to it.


Shift they work, text box autopopulates 1 (based on operator query
column
3)

That's pretty much the set up for this form. When the user selects
something
from the combo box(based on row sources and the text boxes based on
control
sources), other text boxes autopopulate. I hope this makes sense.

I'm sorry to have to tell you it does not make much sense to me. I am
unfamiliar either with the real-world business situation you are
trying
to
address or the structure of your database. If you can post a
description
of
the tables and relationships it may be possible to come up with
something
more definite.

:

With the VBA editor open, click Debug > Compile ___ to compile the
code.
If
you have created a situation such as attempting to requery a field
(rather
than a control), it will highlight the line of code. It also
guards
against
typographical errors, and quite a few other things that will
prevent
the
code from running.
I am not quite sure what to make of something like:
control source = Master Item2 = Forms!FrmJob1!ID.Column(7)
Is MasterItem2 a combo box? If so, Forms!FrmJob1!ID.Column(7)
cannot
be
its
control source. The Control Source is the field to which a control
is
bound. If you have a Contacts table with fields for FirstName,
LastName,
etc., and you create a form bound to the Contacts table for
entering
and
editing contact information, then information typed into a text box
with
its
control source set to FirstName will store that information in the
FirstName
field of the Contacts table.
To elaborate a bit, open a form in design view. Click View >
Properties
(or
double click the small square at the very top left of the form
window).
You
will see a place for the Record Source. If you select a table or a
query
bound to the table as the Record Source, the form is a bound form.
That
is,
it is bound to that record source (table or query). The form
becomes
a
sort
of portal to the table.
Next, the controls. A control is a combo box, text box, label,
line,
or
just about anything else on the form. Some controls, such as text
boxes
and
combo boxes, may be bound to fields in the form's Record Source.
That
is, a
field from the form's Record Source is selected as the control's
Control
Source. Information entered into the bound control (or selected
from
a
combo box list, which accomplishes the same thing as typing into a
text
box)
will be stored in that field in the form's Record Source.
Back to the code you have provided, this cannot do anything I can
see:
Control Source=PS Item 2= " " (8)
Another thing I found puzzling was that you said the info needs to
be
saved
to a new table. Why? It is possible to create a table through
code
and
store information there. I couldn't say exactly how to go about
that,
but I
doubt very much that it is what you need to do.
I think a greater understanding of some of the terminology would be
of
help.
A good place to start is here:
http://allenbrowne.com/tips.html
In particular, look at the Table Design links in the Tips for
Casual
Users.
On the right side of the page, toward the bottom of the list, is a
Links
link. That will take you to quite an extensive list of Access
links
for
users of all levels.

Below are my combo boxes:

Combo Category = Row Source = Select Query
Combo Job = Row Source = Query 5 (Main Query)

Cat ID, Cat code, Job Name, Master item, PS item, Master Desc,
Price,
Master
item 2, ps item2, price2, mat2, job cc, contact

Combo ID = row source = query 5, event procedure after update

text box = count
 
B

BruceM

The syntax for referencing a field on another form is:
[Forms]![Form1]![MaterialA]
I'm not sure if it is necessary to put square brackets around Forms, but
note that you left out an exclamation mark (aka "bang"). If the report is
based on the same record source as the form you could also just repeat the
calculation in the report.
Although I don't know the purpose of your database, when I see that there is
something like MaterialA and MaterialB I wonder if you are thinking in
spreadsheet terms and storing a wide range of information in a flat file.
Unless there are always a fixed number of entries (and maybe even if there
are) it is usually better to store such information in a separate related
table.

Yula said:
Bruce, Thanks Again. I am finished with the form part of the project, but
now
I have to make a report based on the info in the form. I am having trouble
adding calculated controls from the form into the report.
Ex. My calculated control in a form takes the mailed pieces * cost of
material 1. Next control takes mailed pieces * cost of material 2

Material 1 control is named: MaterialA
Material 2 control is named: MaterialB

I want to take the value from that control and put it into a report that
has
a label
materials and below it there is a calculated control called
forms![form1][MaterialA]+
forms![form1][MaterialB]

IS this possible??



BruceM said:
Glad to help. Good luck with the project.

Yula said:
Bruce, Thank you very much, this was very helpful!!!

:

It is ususally a good idea to state the nature of the problem.
"Something
is off" is vague.

I noticed a few things. There was an extra 0 before the first
instance
of
the Date. Also, use Is Null, not = Is Null. Be aware that Date is a
reserved word in Access, and should not be used for a field name. For
a
listing of reserved words, see:
http://www.accessmvp.com/JConrad/accessjunkie/resources.html#ReservedWords
In particular, look at Reserved Words in Microsoft Access and Reserved
Words
in Jet 4.0.
You can get around using a reserved word by enclosing it in brackets,
but
sooner or later you will run into a problem with using reserved words
incorrectly, and it could be difficult to track down.
Having said that, here is your expression, amended.

= IIf( [2oz] ="X" and [Date] < #5/14/2007#,.545,IIf( [2oz] Is Null and
[Date] < #5/14/2007#,.321,IIf( [2oz] = "x" and [Date] >=
#05/14/2007#,.459,IIf(
[2oz] Is Null and [Date] >= #05/14/2007#,.334))))

You can, however, shorten it to something like:
= IIf([2oz] = "X",IIf([Date] < #5/14/07#,.545,.459),IIf([2oz] Is
Null,IIf([Date] < #5/14/07#,.321,.334)))

There are only two choices for the date: before 5/14/07, or else on or
after
5/14/07. You don't need to test for >=, because anything that is not
<
is
automatically >=. If the only two choices are X or null, you can
shorten
it
to:
= IIf([2oz] = "X",IIf([Date] < #5/14/07#,.545,.459),IIf([Date] <
#5/14/07#,.321,.334))
However, if there could be an entry other than X or Null you will need
to
allow for that in the expression:

= IIf([2oz] = "X",IIf([Date] < #5/14/07#,.545,.459),IIf([2oz] Is
Null,IIf([Date] < #5/14/07#,.321,.334),"Other"))

If the expression gets much more involved than that you may do well to
use
VBA, where a wider range of approaches are possible.

Bruce, thanks for your advise! The scope of the project changesd
direction
a
bit. I have another questions, maybe you can help me. I am trying to
create
this IIF statement in a control and something is off, can you take a
look
at
it?


= IIf( [2oz] ="X" and [Date] <0#5/14/2007#,.545,IIf( [2oz] = is Null
and
[Date] <#5/14/2007#,.321,IIf( [2oz] = "x" and [Date]
=#05/14/2007#,.459,IIf(
[2oz] = is Null and [Date] >= #05/14/2007#,.334))))


THANK YOU!

:

Responses inline.

Bruce thank you for all your advise so far, but here is the
problem.
I
have
been working on this project for a while and I really need to
come
up
with
a
form for people to fill out that will store the info that they
fill
in.
I
don't have the luxury any more to learn more termanology, I have
to
show
something for all the time I out in. I leaned access from scratch
and
the
posts that i found here... and I am sure I know maybe 3% of
what's
there,
but
that's not excuse for not getting this project done.

A great deal can be accomplished with just a fraction of the
capabilities
of
Access, but a solid design is essential to using Access properly.
Without
knowing more about how your database is structured or the
real-world
situation it is trying to addess I may not be able to offer many
useful
suggestions. Much can be accomplished with Access, but there is a
substantial learning curve. You may not have enough knowledge of
the
product to get the particular job done. By analogy, having a
learner's
permit, and being familiar with the basics of putting a car into
gear
and
steering it around the neighborhood, does not qualify you to take
part
in
a
road rally. It's not an excuse, it's a fact.


To answer your questions: I ran the compile in VBA and there was
one
problem, I took care of it. When I say Control source = master
Item
#=forms!FrmJob1ID.Column(7), I mean by that the control source in
the
properties sheet for that text box is called master item #.

For what text box? What is Forms!frmJob1ID.Column(7)?

Also, I don't think I would need a "contact" table to be updated
b/c
the
user is selecting from a given list of operators. When they
select
the
operator from the combo box, other text boxes are automatically
populated.

The Contacts table was an example: "If you have a Contacts table
...".
It
is a familiar situation, so I had hoped it would be useful as an
example.


Ex. Combo box Operator. Row souce in properties is called
operator
query
Column 1 shows: Bob, John, Joe, Mike

What is the source for the operator query? Is there an Employee
table
or
something of the sort?


Machine they work on text box: autopopulates 12345 (based on
Operator
query
column 2)

Each operator works on just one machine? Do you mean they operate
the
machine, or is this a shop that repairs machines? "Work on" is a
vague
term. In any case, "machine they work on" is not an attribute of
an
operator, so the information should be stored in a separate table.
If
that
is already the case, and the operator query assembles information
from
several tables, the question remains whether you need to store the
information about machine and shift, or just link to it.


Shift they work, text box autopopulates 1 (based on operator
query
column
3)

That's pretty much the set up for this form. When the user
selects
something
from the combo box(based on row sources and the text boxes based
on
control
sources), other text boxes autopopulate. I hope this makes sense.

I'm sorry to have to tell you it does not make much sense to me. I
am
unfamiliar either with the real-world business situation you are
trying
to
address or the structure of your database. If you can post a
description
of
the tables and relationships it may be possible to come up with
something
more definite.

:

With the VBA editor open, click Debug > Compile ___ to compile
the
code.
If
you have created a situation such as attempting to requery a
field
(rather
than a control), it will highlight the line of code. It also
guards
against
typographical errors, and quite a few other things that will
prevent
the
code from running.
I am not quite sure what to make of something like:
control source = Master Item2 = Forms!FrmJob1!ID.Column(7)
Is MasterItem2 a combo box? If so, Forms!FrmJob1!ID.Column(7)
cannot
be
its
control source. The Control Source is the field to which a
control
is
bound. If you have a Contacts table with fields for FirstName,
LastName,
etc., and you create a form bound to the Contacts table for
entering
and
editing contact information, then information typed into a text
box
with
its
control source set to FirstName will store that information in
the
FirstName
field of the Contacts table.
To elaborate a bit, open a form in design view. Click View >
Properties
(or
double click the small square at the very top left of the form
window).
You
will see a place for the Record Source. If you select a table
or a
query
bound to the table as the Record Source, the form is a bound
form.
That
is,
it is bound to that record source (table or query). The form
becomes
a
sort
of portal to the table.
Next, the controls. A control is a combo box, text box, label,
line,
or
just about anything else on the form. Some controls, such as
text
boxes
and
combo boxes, may be bound to fields in the form's Record Source.
That
is, a
field from the form's Record Source is selected as the control's
Control
Source. Information entered into the bound control (or selected
from
a
combo box list, which accomplishes the same thing as typing into
a
text
box)
will be stored in that field in the form's Record Source.
Back to the code you have provided, this cannot do anything I
can
see:
Control Source=PS Item 2= " " (8)
Another thing I found puzzling was that you said the info needs
to
be
saved
to a new table. Why? It is possible to create a table through
code
and
store information there. I couldn't say exactly how to go about
that,
but I
doubt very much that it is what you need to do.
I think a greater understanding of some of the terminology would
be
of
help.
A good place to start is here:
http://allenbrowne.com/tips.html
In particular, look at the Table Design links in the Tips for
Casual
Users.
On the right side of the page, toward the bottom of the list, is
a
Links
link. That will take you to quite an extensive list of Access
links
for
users of all levels.

Below are my combo boxes:

Combo Category = Row Source = Select Query
Combo Job = Row Source = Query 5 (Main Query)

Cat ID, Cat code, Job Name, Master item, PS item, Master Desc,
Price,
Master
item 2, ps item2, price2, mat2, job cc, contact

Combo ID = row source = query 5, event procedure after update

text box = count
 
Y

Yula

Thanks Bruce, I figured this one out. I have yet another questions about an
IIF statement. I need a calculated field based on the following criteria:

Previous calculation in this field:
PSI: IIF([x is 2oz] ="p",0,[mailed pieces ] *.011) -- This was working fine
until I found out that I have to change the constant based on the date.

I need the same formula only before 5/14/2007 *.013 and after 5/14/2007 its
*.011.

I know you showed me something similar,but I am not sure where the first
part (([x is 2oz] ="p",0)fits into that previous formula.

Thanks again for ALL your help Bruce!

Yula


BruceM said:
The syntax for referencing a field on another form is:
[Forms]![Form1]![MaterialA]
I'm not sure if it is necessary to put square brackets around Forms, but
note that you left out an exclamation mark (aka "bang"). If the report is
based on the same record source as the form you could also just repeat the
calculation in the report.
Although I don't know the purpose of your database, when I see that there is
something like MaterialA and MaterialB I wonder if you are thinking in
spreadsheet terms and storing a wide range of information in a flat file.
Unless there are always a fixed number of entries (and maybe even if there
are) it is usually better to store such information in a separate related
table.

Yula said:
Bruce, Thanks Again. I am finished with the form part of the project, but
now
I have to make a report based on the info in the form. I am having trouble
adding calculated controls from the form into the report.
Ex. My calculated control in a form takes the mailed pieces * cost of
material 1. Next control takes mailed pieces * cost of material 2

Material 1 control is named: MaterialA
Material 2 control is named: MaterialB

I want to take the value from that control and put it into a report that
has
a label
materials and below it there is a calculated control called
forms![form1][MaterialA]+
forms![form1][MaterialB]

IS this possible??



BruceM said:
Glad to help. Good luck with the project.

Bruce, Thank you very much, this was very helpful!!!

:

It is ususally a good idea to state the nature of the problem.
"Something
is off" is vague.

I noticed a few things. There was an extra 0 before the first
instance
of
the Date. Also, use Is Null, not = Is Null. Be aware that Date is a
reserved word in Access, and should not be used for a field name. For
a
listing of reserved words, see:
http://www.accessmvp.com/JConrad/accessjunkie/resources.html#ReservedWords
In particular, look at Reserved Words in Microsoft Access and Reserved
Words
in Jet 4.0.
You can get around using a reserved word by enclosing it in brackets,
but
sooner or later you will run into a problem with using reserved words
incorrectly, and it could be difficult to track down.
Having said that, here is your expression, amended.

= IIf( [2oz] ="X" and [Date] < #5/14/2007#,.545,IIf( [2oz] Is Null and
[Date] < #5/14/2007#,.321,IIf( [2oz] = "x" and [Date] >=
#05/14/2007#,.459,IIf(
[2oz] Is Null and [Date] >= #05/14/2007#,.334))))

You can, however, shorten it to something like:
= IIf([2oz] = "X",IIf([Date] < #5/14/07#,.545,.459),IIf([2oz] Is
Null,IIf([Date] < #5/14/07#,.321,.334)))

There are only two choices for the date: before 5/14/07, or else on or
after
5/14/07. You don't need to test for >=, because anything that is not
<
is
automatically >=. If the only two choices are X or null, you can
shorten
it
to:
= IIf([2oz] = "X",IIf([Date] < #5/14/07#,.545,.459),IIf([Date] <
#5/14/07#,.321,.334))
However, if there could be an entry other than X or Null you will need
to
allow for that in the expression:

= IIf([2oz] = "X",IIf([Date] < #5/14/07#,.545,.459),IIf([2oz] Is
Null,IIf([Date] < #5/14/07#,.321,.334),"Other"))

If the expression gets much more involved than that you may do well to
use
VBA, where a wider range of approaches are possible.

Bruce, thanks for your advise! The scope of the project changesd
direction
a
bit. I have another questions, maybe you can help me. I am trying to
create
this IIF statement in a control and something is off, can you take a
look
at
it?


= IIf( [2oz] ="X" and [Date] <0#5/14/2007#,.545,IIf( [2oz] = is Null
and
[Date] <#5/14/2007#,.321,IIf( [2oz] = "x" and [Date]
=#05/14/2007#,.459,IIf(
[2oz] = is Null and [Date] >= #05/14/2007#,.334))))


THANK YOU!

:

Responses inline.

Bruce thank you for all your advise so far, but here is the
problem.
I
have
been working on this project for a while and I really need to
come
up
with
a
form for people to fill out that will store the info that they
fill
in.
I
don't have the luxury any more to learn more termanology, I have
to
show
something for all the time I out in. I leaned access from scratch
and
the
posts that i found here... and I am sure I know maybe 3% of
what's
there,
but
that's not excuse for not getting this project done.

A great deal can be accomplished with just a fraction of the
capabilities
of
Access, but a solid design is essential to using Access properly.
Without
knowing more about how your database is structured or the
real-world
situation it is trying to addess I may not be able to offer many
useful
suggestions. Much can be accomplished with Access, but there is a
substantial learning curve. You may not have enough knowledge of
the
product to get the particular job done. By analogy, having a
learner's
permit, and being familiar with the basics of putting a car into
gear
and
steering it around the neighborhood, does not qualify you to take
part
in
a
road rally. It's not an excuse, it's a fact.


To answer your questions: I ran the compile in VBA and there was
one
problem, I took care of it. When I say Control source = master
Item
#=forms!FrmJob1ID.Column(7), I mean by that the control source in
the
properties sheet for that text box is called master item #.

For what text box? What is Forms!frmJob1ID.Column(7)?

Also, I don't think I would need a "contact" table to be updated
b/c
the
user is selecting from a given list of operators. When they
select
the
operator from the combo box, other text boxes are automatically
populated.

The Contacts table was an example: "If you have a Contacts table
...".
It
is a familiar situation, so I had hoped it would be useful as an
example.


Ex. Combo box Operator. Row souce in properties is called
operator
query
Column 1 shows: Bob, John, Joe, Mike

What is the source for the operator query? Is there an Employee
table
or
something of the sort?


Machine they work on text box: autopopulates 12345 (based on
Operator
query
column 2)

Each operator works on just one machine? Do you mean they operate
the
machine, or is this a shop that repairs machines? "Work on" is a
vague
term. In any case, "machine they work on" is not an attribute of
an
operator, so the information should be stored in a separate table.
If
that
is already the case, and the operator query assembles information
from
several tables, the question remains whether you need to store the
information about machine and shift, or just link to it.


Shift they work, text box autopopulates 1 (based on operator
query
column
3)

That's pretty much the set up for this form. When the user
selects
something
from the combo box(based on row sources and the text boxes based
on
control
sources), other text boxes autopopulate. I hope this makes sense.

I'm sorry to have to tell you it does not make much sense to me. I
am
unfamiliar either with the real-world business situation you are
trying
to
address or the structure of your database. If you can post a
description
of
the tables and relationships it may be possible to come up with
something
more definite.

:

With the VBA editor open, click Debug > Compile ___ to compile
the
code.
If
you have created a situation such as attempting to requery a
field
(rather
than a control), it will highlight the line of code. It also
guards
against
typographical errors, and quite a few other things that will
prevent
the
code from running.
I am not quite sure what to make of something like:
control source = Master Item2 = Forms!FrmJob1!ID.Column(7)
Is MasterItem2 a combo box? If so, Forms!FrmJob1!ID.Column(7)
cannot
be
its
control source. The Control Source is the field to which a
control
is
bound. If you have a Contacts table with fields for FirstName,
LastName,
etc., and you create a form bound to the Contacts table for
entering
and
editing contact information, then information typed into a text
box
with
its
control source set to FirstName will store that information in
the
FirstName
field of the Contacts table.
To elaborate a bit, open a form in design view. Click View >
Properties
(or
double click the small square at the very top left of the form
window).
 
B

BruceM

Just substitute another IIf for the number:
PSI: IIF([x is 2oz] ="p",0,[mailed pieces ] * IIf([DateField] <=
#5/14/07#,.013,.011))

As an aside, you will probably find it helpful over time to keep spaces and
special characters other than undrscores out of field names.

Yula said:
Thanks Bruce, I figured this one out. I have yet another questions about
an
IIF statement. I need a calculated field based on the following criteria:

Previous calculation in this field:
PSI: IIF([x is 2oz] ="p",0,[mailed pieces ] *.011) -- This was working
fine
until I found out that I have to change the constant based on the date.

I need the same formula only before 5/14/2007 *.013 and after 5/14/2007
its
*.011.

I know you showed me something similar,but I am not sure where the first
part (([x is 2oz] ="p",0)fits into that previous formula.

Thanks again for ALL your help Bruce!

Yula


BruceM said:
The syntax for referencing a field on another form is:
[Forms]![Form1]![MaterialA]
I'm not sure if it is necessary to put square brackets around Forms, but
note that you left out an exclamation mark (aka "bang"). If the report
is
based on the same record source as the form you could also just repeat
the
calculation in the report.
Although I don't know the purpose of your database, when I see that there
is
something like MaterialA and MaterialB I wonder if you are thinking in
spreadsheet terms and storing a wide range of information in a flat file.
Unless there are always a fixed number of entries (and maybe even if
there
are) it is usually better to store such information in a separate related
table.

Yula said:
Bruce, Thanks Again. I am finished with the form part of the project,
but
now
I have to make a report based on the info in the form. I am having
trouble
adding calculated controls from the form into the report.
Ex. My calculated control in a form takes the mailed pieces * cost of
material 1. Next control takes mailed pieces * cost of material 2

Material 1 control is named: MaterialA
Material 2 control is named: MaterialB

I want to take the value from that control and put it into a report
that
has
a label
materials and below it there is a calculated control called
forms![form1][MaterialA]+
forms![form1][MaterialB]

IS this possible??



:

Glad to help. Good luck with the project.

Bruce, Thank you very much, this was very helpful!!!

:

It is ususally a good idea to state the nature of the problem.
"Something
is off" is vague.

I noticed a few things. There was an extra 0 before the first
instance
of
the Date. Also, use Is Null, not = Is Null. Be aware that Date is
a
reserved word in Access, and should not be used for a field name.
For
a
listing of reserved words, see:
http://www.accessmvp.com/JConrad/accessjunkie/resources.html#ReservedWords
In particular, look at Reserved Words in Microsoft Access and
Reserved
Words
in Jet 4.0.
You can get around using a reserved word by enclosing it in
brackets,
but
sooner or later you will run into a problem with using reserved
words
incorrectly, and it could be difficult to track down.
Having said that, here is your expression, amended.

= IIf( [2oz] ="X" and [Date] < #5/14/2007#,.545,IIf( [2oz] Is Null
and
[Date] < #5/14/2007#,.321,IIf( [2oz] = "x" and [Date] >=
#05/14/2007#,.459,IIf(
[2oz] Is Null and [Date] >= #05/14/2007#,.334))))

You can, however, shorten it to something like:
= IIf([2oz] = "X",IIf([Date] < #5/14/07#,.545,.459),IIf([2oz] Is
Null,IIf([Date] < #5/14/07#,.321,.334)))

There are only two choices for the date: before 5/14/07, or else on
or
after
5/14/07. You don't need to test for >=, because anything that is
not
<
is
automatically >=. If the only two choices are X or null, you can
shorten
it
to:
= IIf([2oz] = "X",IIf([Date] < #5/14/07#,.545,.459),IIf([Date] <
#5/14/07#,.321,.334))
However, if there could be an entry other than X or Null you will
need
to
allow for that in the expression:

= IIf([2oz] = "X",IIf([Date] < #5/14/07#,.545,.459),IIf([2oz] Is
Null,IIf([Date] < #5/14/07#,.321,.334),"Other"))

If the expression gets much more involved than that you may do well
to
use
VBA, where a wider range of approaches are possible.

Bruce, thanks for your advise! The scope of the project changesd
direction
a
bit. I have another questions, maybe you can help me. I am trying
to
create
this IIF statement in a control and something is off, can you
take a
look
at
it?


= IIf( [2oz] ="X" and [Date] <0#5/14/2007#,.545,IIf( [2oz] = is
Null
and
[Date] <#5/14/2007#,.321,IIf( [2oz] = "x" and [Date]
=#05/14/2007#,.459,IIf(
[2oz] = is Null and [Date] >= #05/14/2007#,.334))))


THANK YOU!

:

Responses inline.

Bruce thank you for all your advise so far, but here is the
problem.
I
have
been working on this project for a while and I really need to
come
up
with
a
form for people to fill out that will store the info that they
fill
in.
I
don't have the luxury any more to learn more termanology, I
have
to
show
something for all the time I out in. I leaned access from
scratch
and
the
posts that i found here... and I am sure I know maybe 3% of
what's
there,
but
that's not excuse for not getting this project done.

A great deal can be accomplished with just a fraction of the
capabilities
of
Access, but a solid design is essential to using Access
properly.
Without
knowing more about how your database is structured or the
real-world
situation it is trying to addess I may not be able to offer many
useful
suggestions. Much can be accomplished with Access, but there is
a
substantial learning curve. You may not have enough knowledge
of
the
product to get the particular job done. By analogy, having a
learner's
permit, and being familiar with the basics of putting a car into
gear
and
steering it around the neighborhood, does not qualify you to
take
part
in
a
road rally. It's not an excuse, it's a fact.


To answer your questions: I ran the compile in VBA and there
was
one
problem, I took care of it. When I say Control source = master
Item
#=forms!FrmJob1ID.Column(7), I mean by that the control source
in
the
properties sheet for that text box is called master item #.

For what text box? What is Forms!frmJob1ID.Column(7)?

Also, I don't think I would need a "contact" table to be
updated
b/c
the
user is selecting from a given list of operators. When they
select
the
operator from the combo box, other text boxes are
automatically
populated.

The Contacts table was an example: "If you have a Contacts
table
...".
It
is a familiar situation, so I had hoped it would be useful as an
example.


Ex. Combo box Operator. Row souce in properties is called
operator
query
Column 1 shows: Bob, John, Joe, Mike

What is the source for the operator query? Is there an Employee
table
or
something of the sort?


Machine they work on text box: autopopulates 12345 (based on
Operator
query
column 2)

Each operator works on just one machine? Do you mean they
operate
the
machine, or is this a shop that repairs machines? "Work on" is
a
vague
term. In any case, "machine they work on" is not an attribute
of
an
operator, so the information should be stored in a separate
table.
If
that
is already the case, and the operator query assembles
information
from
several tables, the question remains whether you need to store
the
information about machine and shift, or just link to it.


Shift they work, text box autopopulates 1 (based on operator
query
column
3)

That's pretty much the set up for this form. When the user
selects
something
from the combo box(based on row sources and the text boxes
based
on
control
sources), other text boxes autopopulate. I hope this makes
sense.

I'm sorry to have to tell you it does not make much sense to me.
I
am
unfamiliar either with the real-world business situation you are
trying
to
address or the structure of your database. If you can post a
description
of
the tables and relationships it may be possible to come up with
something
more definite.

:

With the VBA editor open, click Debug > Compile ___ to
compile
the
code.
If
you have created a situation such as attempting to requery a
field
(rather
than a control), it will highlight the line of code. It also
guards
against
typographical errors, and quite a few other things that will
prevent
the
code from running.
I am not quite sure what to make of something like:
control source = Master Item2 = Forms!FrmJob1!ID.Column(7)
Is MasterItem2 a combo box? If so,
Forms!FrmJob1!ID.Column(7)
cannot
be
its
control source. The Control Source is the field to which a
control
is
bound. If you have a Contacts table with fields for
FirstName,
LastName,
etc., and you create a form bound to the Contacts table for
entering
and
editing contact information, then information typed into a
text
box
with
its
control source set to FirstName will store that information
in
the
FirstName
field of the Contacts table.
To elaborate a bit, open a form in design view. Click View >
Properties
(or
double click the small square at the very top left of the
form
window).
 
Y

Yula

Thank you on once again. I can think thru the logic, I am just having a hard
time with the syntex.

BruceM said:
Just substitute another IIf for the number:
PSI: IIF([x is 2oz] ="p",0,[mailed pieces ] * IIf([DateField] <=
#5/14/07#,.013,.011))

As an aside, you will probably find it helpful over time to keep spaces and
special characters other than undrscores out of field names.

Yula said:
Thanks Bruce, I figured this one out. I have yet another questions about
an
IIF statement. I need a calculated field based on the following criteria:

Previous calculation in this field:
PSI: IIF([x is 2oz] ="p",0,[mailed pieces ] *.011) -- This was working
fine
until I found out that I have to change the constant based on the date.

I need the same formula only before 5/14/2007 *.013 and after 5/14/2007
its
*.011.

I know you showed me something similar,but I am not sure where the first
part (([x is 2oz] ="p",0)fits into that previous formula.

Thanks again for ALL your help Bruce!

Yula


BruceM said:
The syntax for referencing a field on another form is:
[Forms]![Form1]![MaterialA]
I'm not sure if it is necessary to put square brackets around Forms, but
note that you left out an exclamation mark (aka "bang"). If the report
is
based on the same record source as the form you could also just repeat
the
calculation in the report.
Although I don't know the purpose of your database, when I see that there
is
something like MaterialA and MaterialB I wonder if you are thinking in
spreadsheet terms and storing a wide range of information in a flat file.
Unless there are always a fixed number of entries (and maybe even if
there
are) it is usually better to store such information in a separate related
table.

Bruce, Thanks Again. I am finished with the form part of the project,
but
now
I have to make a report based on the info in the form. I am having
trouble
adding calculated controls from the form into the report.
Ex. My calculated control in a form takes the mailed pieces * cost of
material 1. Next control takes mailed pieces * cost of material 2

Material 1 control is named: MaterialA
Material 2 control is named: MaterialB

I want to take the value from that control and put it into a report
that
has
a label
materials and below it there is a calculated control called
forms![form1][MaterialA]+
forms![form1][MaterialB]

IS this possible??



:

Glad to help. Good luck with the project.

Bruce, Thank you very much, this was very helpful!!!

:

It is ususally a good idea to state the nature of the problem.
"Something
is off" is vague.

I noticed a few things. There was an extra 0 before the first
instance
of
the Date. Also, use Is Null, not = Is Null. Be aware that Date is
a
reserved word in Access, and should not be used for a field name.
For
a
listing of reserved words, see:
http://www.accessmvp.com/JConrad/accessjunkie/resources.html#ReservedWords
In particular, look at Reserved Words in Microsoft Access and
Reserved
Words
in Jet 4.0.
You can get around using a reserved word by enclosing it in
brackets,
but
sooner or later you will run into a problem with using reserved
words
incorrectly, and it could be difficult to track down.
Having said that, here is your expression, amended.

= IIf( [2oz] ="X" and [Date] < #5/14/2007#,.545,IIf( [2oz] Is Null
and
[Date] < #5/14/2007#,.321,IIf( [2oz] = "x" and [Date] >=
#05/14/2007#,.459,IIf(
[2oz] Is Null and [Date] >= #05/14/2007#,.334))))

You can, however, shorten it to something like:
= IIf([2oz] = "X",IIf([Date] < #5/14/07#,.545,.459),IIf([2oz] Is
Null,IIf([Date] < #5/14/07#,.321,.334)))

There are only two choices for the date: before 5/14/07, or else on
or
after
5/14/07. You don't need to test for >=, because anything that is
not
<
is
automatically >=. If the only two choices are X or null, you can
shorten
it
to:
= IIf([2oz] = "X",IIf([Date] < #5/14/07#,.545,.459),IIf([Date] <
#5/14/07#,.321,.334))
However, if there could be an entry other than X or Null you will
need
to
allow for that in the expression:

= IIf([2oz] = "X",IIf([Date] < #5/14/07#,.545,.459),IIf([2oz] Is
Null,IIf([Date] < #5/14/07#,.321,.334),"Other"))

If the expression gets much more involved than that you may do well
to
use
VBA, where a wider range of approaches are possible.

Bruce, thanks for your advise! The scope of the project changesd
direction
a
bit. I have another questions, maybe you can help me. I am trying
to
create
this IIF statement in a control and something is off, can you
take a
look
at
it?


= IIf( [2oz] ="X" and [Date] <0#5/14/2007#,.545,IIf( [2oz] = is
Null
and
[Date] <#5/14/2007#,.321,IIf( [2oz] = "x" and [Date]
=#05/14/2007#,.459,IIf(
[2oz] = is Null and [Date] >= #05/14/2007#,.334))))


THANK YOU!

:

Responses inline.

Bruce thank you for all your advise so far, but here is the
problem.
I
have
been working on this project for a while and I really need to
come
up
with
a
form for people to fill out that will store the info that they
fill
in.
I
don't have the luxury any more to learn more termanology, I
have
to
show
something for all the time I out in. I leaned access from
scratch
and
the
posts that i found here... and I am sure I know maybe 3% of
what's
there,
but
that's not excuse for not getting this project done.

A great deal can be accomplished with just a fraction of the
capabilities
of
Access, but a solid design is essential to using Access
properly.
Without
knowing more about how your database is structured or the
real-world
situation it is trying to addess I may not be able to offer many
useful
suggestions. Much can be accomplished with Access, but there is
a
substantial learning curve. You may not have enough knowledge
of
the
product to get the particular job done. By analogy, having a
learner's
permit, and being familiar with the basics of putting a car into
gear
and
steering it around the neighborhood, does not qualify you to
take
part
in
a
road rally. It's not an excuse, it's a fact.


To answer your questions: I ran the compile in VBA and there
was
one
problem, I took care of it. When I say Control source = master
Item
#=forms!FrmJob1ID.Column(7), I mean by that the control source
in
the
properties sheet for that text box is called master item #.

For what text box? What is Forms!frmJob1ID.Column(7)?

Also, I don't think I would need a "contact" table to be
updated
b/c
the
user is selecting from a given list of operators. When they
select
the
operator from the combo box, other text boxes are
automatically
populated.

The Contacts table was an example: "If you have a Contacts
table
...".
It
is a familiar situation, so I had hoped it would be useful as an
example.


Ex. Combo box Operator. Row souce in properties is called
operator
query
Column 1 shows: Bob, John, Joe, Mike

What is the source for the operator query? Is there an Employee
table
or
something of the sort?


Machine they work on text box: autopopulates 12345 (based on
Operator
query
column 2)

Each operator works on just one machine? Do you mean they
operate
the
machine, or is this a shop that repairs machines? "Work on" is
a
vague
term. In any case, "machine they work on" is not an attribute
of
an
operator, so the information should be stored in a separate
table.
If
that
is already the case, and the operator query assembles
information
from
several tables, the question remains whether you need to store
the
information about machine and shift, or just link to it.
 
Top