A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

using multiple fields from a table



 
 
Thread Tools Display Modes
  #1  
Old April 8th, 2010, 07:10 PM posted to microsoft.public.access.forms
shymousee
external usenet poster
 
Posts: 2
Default using multiple fields from a table

I am trying to use one table with multiple fields in a notinlist pop up. The
name of the table is equipment. It has 2 fields in it, equipment and toners.
No matter what I try, I get an error message saying the item is not on the
list. If I change the statement
strSQL = "INSERT INTO equipment([equipment]) " & _
"VALUES ('" & NewData & "');"
to

strSQL = "INSERT INTO equipment([toners]) " & _
"VALUES ('" & NewData & "');"

I get the message, The text you entered isn't an item in the list. Select
an item from the list, or enter text that matches one of the listed items.
This is after I get a message saying the item was added.

I am trying to combine some tables instead of having a bunch of tables for
each time I want to use the notinlist option.

Private Sub toner_NotInList(NewData As String, Response As Integer)
On Error GoTo equipment_NotInList_Err
Dim intAnswer As Integer
Dim strSQL As String
intAnswer = MsgBox("The equipment " & Chr(34) & NewData & _
Chr(34) & " is not currently listed." & vbCrLf & _
"Would you like to add it to the list now?" _
, vbQuestion + vbYesNo, "property")
If intAnswer = vbYes Then
strSQL = "INSERT INTO equipment([equipment]) " & _
"VALUES ('" & NewData & "');"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
MsgBox "The new equipment has been added to the list." _
, vbInformation, "property"
Response = acDataErrAdded
Else
MsgBox "Please choose a equipment from the list." _
, vbInformation, "property"
Response = acDataErrContinue
End If
equipment_NotInList_Exit:
Exit Sub
equipment_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume equipment_NotInList_Exit
End Sub
  #2  
Old April 8th, 2010, 07:30 PM posted to microsoft.public.access.forms
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default using multiple fields from a table

How depends on what ... and I don't have a very clear picture of what data
you are working with underneath the form you seem to be trying to do this
in...

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

"shymousee" wrote in message
...
I am trying to use one table with multiple fields in a notinlist pop up.
The
name of the table is equipment. It has 2 fields in it, equipment and
toners.
No matter what I try, I get an error message saying the item is not on the
list. If I change the statement
strSQL = "INSERT INTO equipment([equipment]) " & _
"VALUES ('" & NewData & "');"
to

strSQL = "INSERT INTO equipment([toners]) " & _
"VALUES ('" & NewData & "');"

I get the message, The text you entered isn't an item in the list. Select
an item from the list, or enter text that matches one of the listed items.
This is after I get a message saying the item was added.

I am trying to combine some tables instead of having a bunch of tables for
each time I want to use the notinlist option.

Private Sub toner_NotInList(NewData As String, Response As Integer)
On Error GoTo equipment_NotInList_Err
Dim intAnswer As Integer
Dim strSQL As String
intAnswer = MsgBox("The equipment " & Chr(34) & NewData & _
Chr(34) & " is not currently listed." & vbCrLf & _
"Would you like to add it to the list now?" _
, vbQuestion + vbYesNo, "property")
If intAnswer = vbYes Then
strSQL = "INSERT INTO equipment([equipment]) " & _
"VALUES ('" & NewData & "');"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
MsgBox "The new equipment has been added to the list." _
, vbInformation, "property"
Response = acDataErrAdded
Else
MsgBox "Please choose a equipment from the list." _
, vbInformation, "property"
Response = acDataErrContinue
End If
equipment_NotInList_Exit:
Exit Sub
equipment_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume equipment_NotInList_Exit
End Sub



  #3  
Old April 9th, 2010, 01:17 AM posted to microsoft.public.access.forms
shymousee
external usenet poster
 
Posts: 2
Default using multiple fields from a table

I am trying to keep track of the toner that we purchase. Since I already had
a table that contained the equipment that we purchased, I thought I would add
another field to the equipment table and this would eliminate a table.

The form I am working with contains the name of the toner, what printer the
toner is for,the cost of the toner, shipping, total of the order, the amount
of toner ordered and how many have been used. I have a formula that
calculates the amount of the order.

I would like to be able to use the second field in the equipment table to
add the toner information.

I hope this helps explain things more.

"Jeff Boyce" wrote:

How depends on what ... and I don't have a very clear picture of what data
you are working with underneath the form you seem to be trying to do this
in...

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

"shymousee" wrote in message
...
I am trying to use one table with multiple fields in a notinlist pop up.
The
name of the table is equipment. It has 2 fields in it, equipment and
toners.
No matter what I try, I get an error message saying the item is not on the
list. If I change the statement
strSQL = "INSERT INTO equipment([equipment]) " & _
"VALUES ('" & NewData & "');"
to

strSQL = "INSERT INTO equipment([toners]) " & _
"VALUES ('" & NewData & "');"

I get the message, The text you entered isn't an item in the list. Select
an item from the list, or enter text that matches one of the listed items.
This is after I get a message saying the item was added.

I am trying to combine some tables instead of having a bunch of tables for
each time I want to use the notinlist option.

Private Sub toner_NotInList(NewData As String, Response As Integer)
On Error GoTo equipment_NotInList_Err
Dim intAnswer As Integer
Dim strSQL As String
intAnswer = MsgBox("The equipment " & Chr(34) & NewData & _
Chr(34) & " is not currently listed." & vbCrLf & _
"Would you like to add it to the list now?" _
, vbQuestion + vbYesNo, "property")
If intAnswer = vbYes Then
strSQL = "INSERT INTO equipment([equipment]) " & _
"VALUES ('" & NewData & "');"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
MsgBox "The new equipment has been added to the list." _
, vbInformation, "property"
Response = acDataErrAdded
Else
MsgBox "Please choose a equipment from the list." _
, vbInformation, "property"
Response = acDataErrContinue
End If
equipment_NotInList_Exit:
Exit Sub
equipment_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume equipment_NotInList_Exit
End Sub



.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 03:12 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.