Hi Everyone,
I have form 'AddMultipleItems' with fields as follows
CategoryID Number
ProductID Number
Date_Acquired Date/Time
StatusID Number
txtN unbound number
When you click the Create button it adds txtN amount of records to 'Itemtbl'
with (~)fields filled in
Itemtbl has information
~ItemID Autonumber
~CategoryID Number
~ProductID Number
~Date_Acquired Date/Time
~StatusID Number
Serial_Number Text
AssetNo Text
Comments Text
The purpose of this is to allow a person to create multiple items with the
same product details in one hit and then open a form which lists the items
just created with only the Serial Number and Asset No fields to update so a
barcode scanner can be employed.
I was looking at something like the below but am fairly certain i am offroad
with this one.
Dim stDocName As String
Dim stLinkCriteria As String
Dim txtnn As Integer
txtnn = Me!TxtN
stDocName = "multipleitemadddetails"
stoops = "SELECT TOP txtnn ItemID FROM [itemtbl] ORDER BY ItemID DESC;"
DoCmd.openform stDocName, , , , , , stoops
Any help appreciated! Let me know if you need more info -
Lou
|
|
0
|
|
|
|
Reply
|
Utf
|
11/26/2009 4:54:02 AM |
|
Just to clarify,
I have the code
Dim db As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("itemtbl")
With rs
For a = 1 To TxtN
..AddNew
!ProductID = ProductID
!CategoryID = CategoryID
!StatusID = 1
!Date_Acquired = Date_Aquired
..Update
Next a
End With
rs.close
to create records in the itemtbl and what i am stuck with is how to open a
new form which shows the last txtN amount of records (top txtn itemid order
by itemid desc) was kinda where i was trying to head... i'm not really sure
about this one as you might be able to tell!
Thanks
"8l2255" wrote:
> Hi Everyone,
>
> I have form 'AddMultipleItems' with fields as follows
>
> CategoryID Number
> ProductID Number
> Date_Acquired Date/Time
> StatusID Number
> txtN unbound number
>
> When you click the Create button it adds txtN amount of records to 'Itemtbl'
> with (~)fields filled in
>
> Itemtbl has information
>
> ~ItemID Autonumber
> ~CategoryID Number
> ~ProductID Number
> ~Date_Acquired Date/Time
> ~StatusID Number
> Serial_Number Text
> AssetNo Text
> Comments Text
>
> The purpose of this is to allow a person to create multiple items with the
> same product details in one hit and then open a form which lists the items
> just created with only the Serial Number and Asset No fields to update so a
> barcode scanner can be employed.
>
> I was looking at something like the below but am fairly certain i am offroad
> with this one.
>
> Dim stDocName As String
> Dim stLinkCriteria As String
> Dim txtnn As Integer
> txtnn = Me!TxtN
>
> stDocName = "multipleitemadddetails"
>
> stoops = "SELECT TOP txtnn ItemID FROM [itemtbl] ORDER BY ItemID DESC;"
>
> DoCmd.openform stDocName, , , , , , stoops
>
> Any help appreciated! Let me know if you need more info -
>
> Lou
|
|
0
|
|
|
|
Reply
|
Utf
|
11/26/2009 5:28:02 AM
|
|
8l2255 wrote:
>I have form 'AddMultipleItems' with fields as follows
>
>CategoryID Number
>ProductID Number
>Date_Acquired Date/Time
>StatusID Number
>txtN unbound number
>
>When you click the Create button it adds txtN amount of records to 'Itemtbl'
>with (~)fields filled in
>
>Itemtbl has information
>
>~ItemID Autonumber
>~CategoryID Number
>~ProductID Number
>~Date_Acquired Date/Time
>~StatusID Number
>Serial_Number Text
>AssetNo Text
>Comments Text
>
>The purpose of this is to allow a person to create multiple items with the
>same product details in one hit and then open a form which lists the items
>just created with only the Serial Number and Asset No fields to update so a
>barcode scanner can be employed.
>
>I was looking at something like the below but am fairly certain i am offroad
>with this one.
>
>Dim stDocName As String
>Dim stLinkCriteria As String
>Dim txtnn As Integer
>txtnn = Me!TxtN
>
> stDocName = "multipleitemadddetails"
>
> stoops = "SELECT TOP txtnn ItemID FROM [itemtbl] ORDER BY ItemID DESC;"
>
> DoCmd.openform stDocName, , , , , , stoops
>
That's actually pretty close. Try this:
stoops = "SELECT TOP " & txtnn & " * " _
& "FROM itemtbl ORDER BY ItemID DESC"
DoCmd.openform stDocName, , , , , , stoops
Then, in the form's Open event:
Me.RecordSource = Me.OpenArgs
However, there is one concern. Where does the value of
ItemID come from and how do you guarantee that the new
ItemID values are the top ones? If it's an AutoNumber field
in the table, there are no guarantees because they can go
negative. OTOH, if you are generating the ItemID in your
code, then you don't need to use a TOP query because you can
remember the ID of the first record added and the query can
retrieve all records with ItemID >= the first added ItemID
using WhereCondition instead of OpenArgs.
--
Marsh
MVP [MS Access]
|
|
0
|
|
|
|
Reply
|
Marshall
|
11/26/2009 4:25:13 PM
|
|
Thanks Marshall.
When I use that code i receive an error "expected end of statement" for the
" * " component.
"Marshall Barton" wrote:
> 8l2255 wrote:
> >I have form 'AddMultipleItems' with fields as follows
> >
> >CategoryID Number
> >ProductID Number
> >Date_Acquired Date/Time
> >StatusID Number
> >txtN unbound number
> >
> >When you click the Create button it adds txtN amount of records to 'Itemtbl'
> >with (~)fields filled in
> >
> >Itemtbl has information
> >
> >~ItemID Autonumber
> >~CategoryID Number
> >~ProductID Number
> >~Date_Acquired Date/Time
> >~StatusID Number
> >Serial_Number Text
> >AssetNo Text
> >Comments Text
> >
> >The purpose of this is to allow a person to create multiple items with the
> >same product details in one hit and then open a form which lists the items
> >just created with only the Serial Number and Asset No fields to update so a
> >barcode scanner can be employed.
> >
> >I was looking at something like the below but am fairly certain i am offroad
> >with this one.
> >
> >Dim stDocName As String
> >Dim stLinkCriteria As String
> >Dim txtnn As Integer
> >txtnn = Me!TxtN
> >
> > stDocName = "multipleitemadddetails"
> >
> > stoops = "SELECT TOP txtnn ItemID FROM [itemtbl] ORDER BY ItemID DESC;"
> >
> > DoCmd.openform stDocName, , , , , , stoops
> >
>
>
> That's actually pretty close. Try this:
>
> stoops = "SELECT TOP " & txtnn & " * " _
> & "FROM itemtbl ORDER BY ItemID DESC"
> DoCmd.openform stDocName, , , , , , stoops
>
>
> Then, in the form's Open event:
>
> Me.RecordSource = Me.OpenArgs
>
> However, there is one concern. Where does the value of
> ItemID come from and how do you guarantee that the new
> ItemID values are the top ones? If it's an AutoNumber field
> in the table, there are no guarantees because they can go
> negative. OTOH, if you are generating the ItemID in your
> code, then you don't need to use a TOP query because you can
> remember the ID of the first record added and the query can
> retrieve all records with ItemID >= the first added ItemID
> using WhereCondition instead of OpenArgs.
>
> --
> Marsh
> MVP [MS Access]
> .
>
|
|
0
|
|
|
|
Reply
|
Utf
|
11/26/2009 10:44:01 PM
|
|
my mistake! i think i entered the code wrong the first time.
However, when the form opens it just brings up #Name? in all the fields.
"Marshall Barton" wrote:
> 8l2255 wrote:
> >I have form 'AddMultipleItems' with fields as follows
> >
> >CategoryID Number
> >ProductID Number
> >Date_Acquired Date/Time
> >StatusID Number
> >txtN unbound number
> >
> >When you click the Create button it adds txtN amount of records to 'Itemtbl'
> >with (~)fields filled in
> >
> >Itemtbl has information
> >
> >~ItemID Autonumber
> >~CategoryID Number
> >~ProductID Number
> >~Date_Acquired Date/Time
> >~StatusID Number
> >Serial_Number Text
> >AssetNo Text
> >Comments Text
> >
> >The purpose of this is to allow a person to create multiple items with the
> >same product details in one hit and then open a form which lists the items
> >just created with only the Serial Number and Asset No fields to update so a
> >barcode scanner can be employed.
> >
> >I was looking at something like the below but am fairly certain i am offroad
> >with this one.
> >
> >Dim stDocName As String
> >Dim stLinkCriteria As String
> >Dim txtnn As Integer
> >txtnn = Me!TxtN
> >
> > stDocName = "multipleitemadddetails"
> >
> > stoops = "SELECT TOP txtnn ItemID FROM [itemtbl] ORDER BY ItemID DESC;"
> >
> > DoCmd.openform stDocName, , , , , , stoops
> >
>
>
> That's actually pretty close. Try this:
>
> stoops = "SELECT TOP " & txtnn & " * " _
> & "FROM itemtbl ORDER BY ItemID DESC"
> DoCmd.openform stDocName, , , , , , stoops
>
>
> Then, in the form's Open event:
>
> Me.RecordSource = Me.OpenArgs
>
> However, there is one concern. Where does the value of
> ItemID come from and how do you guarantee that the new
> ItemID values are the top ones? If it's an AutoNumber field
> in the table, there are no guarantees because they can go
> negative. OTOH, if you are generating the ItemID in your
> code, then you don't need to use a TOP query because you can
> remember the ID of the first record added and the query can
> retrieve all records with ItemID >= the first added ItemID
> using WhereCondition instead of OpenArgs.
>
> --
> Marsh
> MVP [MS Access]
> .
>
|
|
0
|
|
|
|
Reply
|
Utf
|
11/26/2009 10:56:01 PM
|
|
8l2255 wrote:
>However, when the form opens it just brings up #Name? in all the fields.
It sounds like you did not set the form's RecordSource in
its record source or the form controls sre not bound to the
fields in Itemtbl.
You might get more information if you put a break point on
the form's Open Open event and test. When the code stops,
Copy the SQL string from OpenArgs to a new query's SQL view
and open the query.
--
Marsh
MVP [MS Access]
|
|
0
|
|
|
|
Reply
|
Marshall
|
11/27/2009 4:26:35 PM
|
|
|
5 Replies
573 Views
(page loaded in 0.1 seconds)
Similiar Articles: OpenForm to show Last n Records - microsoft.public.access ...Hi Everyone, I have form 'AddMultipleItems' with fields as follows CategoryID Number ProductID Number Date_Acquired Date/Time StatusID Num... open form, show all records but go to a specific record ...OpenForm to show Last n Records - microsoft.public.access ... open form, show all records but go to a specific record ... open continuous form - shows 1st record not last ... OpenArgs is null? - microsoft.public.accessOpenForm to show Last n Records - microsoft.public.access ... When the code stops, Copy the SQL string from OpenArgs to a new query's SQL view and ... Open form and if no matching records create a new record ...OpenForm to show Last n Records - microsoft.public.access ... Open form and if no matching records create a new record ... Last n Records - microsoft.public.access ... Open form for add/edit records - microsoft.public.access.forms ...OpenForm to show Last n Records - microsoft.public.access ... How to open a blank form for adding a new record - microsoft ... open continuous form - shows 1st record not ... open continuous form - shows 1st record not last.. - microsoft ...OpenForm to show Last n Records - microsoft.public.access ... open continuous form - shows 1st record not last.. - microsoft ... OpenForm to show Last n Records ... Multiple fields in stLinkCriteria - microsoft.public.access ...Multiple fields in stLinkCriteria - microsoft.public.access ... OpenForm to show Last n Records - microsoft.public.access ... Multiple fields in stLinkCriteria ... help with code to open form with openargs - microsoft.public ...OpenForm to show Last n Records - microsoft.public.access ... help with code to open form with openargs - microsoft.public ... OpenForm ... stDocName, , , , , , stoops Any ... Trying to display records that are 6 months old - microsoft.public ...OpenForm to show Last n Records - microsoft.public.access ... Trying to display records that are 6 months old - microsoft.public ... I have been trying to figure out how ... How to sum all the records, excluding the top N ones? - microsoft ...OpenForm to show Last n Records - microsoft.public.access ... How to sum all the records, excluding the top N ones? - microsoft ... OpenForm to show Last n Records ... OpenForm to show Last n Records - microsoft.public.access ...Hi Everyone, I have form 'AddMultipleItems' with fields as follows CategoryID Number ProductID Number Date_Acquired Date/Time StatusID Num... Open Form on Last Record - Access World ForumsMicrosoft Access Discussion > Modules & VBA ... I have a switchboard that lets you choose between three forms. Each of the three ... It sounds like your sub-form is ... opening a form at the last record - Access World Forums... tables, I have tried to use a macro attached to the open form event to goto the last record. ... when you open the form it should run the macro and display the last record MS ACCESS :: Open A Form And Display Last RecordOpen A Form And Display Last Record Hi, I've searched for this but can't find how to ... Open Form In Last Record; Open Form To New Record; Open Form To A New Record Open form to a specific Record, but show all records?? - Microsoft ...Open form to a specific Record, but show all records??. Microsoft Access / VBA Forums on Bytes. 7/21/2012 5:54:12 PM
|