Is there any way to create a new record (using the following code or similair) - DoCmd.GoToRecord , , acNewRec
But have it carry through certain values from the previous form you have created?
The reson being, I want to be able to create a lot of site records at once, all with the same customer, and same project name. Obviously, getting the customer and project name, etc from the main project setup screen is no problem as you just use openArgs, but I cant see a way of doing it once in the form, and obviusly when you click new, it loses all the openargs.
Any ideas anyone?
5 2890
I will admit, that I haven't actually tested it, but I don't THINK that the form looses the OpenArgs when you create a new record. So you should be able to just add code beneath the line you allready have: - DoCmd.GoToRecord , , acNewRec
-
If Me.OpenArgs & ""<>"" then
-
'Assuming you have only passed 1 value, the project ID
-
Me.tb_ProjectID=clng(Me.OpenArgs)
-
End If
-
Presumably if I were to want more than one openargs, I could split it using: -
Dim StrOpenArgs as string
-
StrOpenargs = Split(Me.Openargs, ";")
-
Me.tb_ProjectID=clng(StrOpenArgs(0))
-
and so on... Or would that not work?
If you get the syntax correct :P - Dim StrOpenArgs() as string
Notice the added (), to indicate its an array.
What I personally use/prefer is to encode my strings in an xml like format.
Lets presume I want to pass on information to a form, saying its type and ID.
I would do like This: - dim strArgs as string
-
strArgs="<Type>" & me.Tb_Type & "</Type><ID> & me.Tb_ID & "</ID>"
-
docmd.OpenForm "frm_Example",,,,,,strArgs
Then I have code in a module: - Public Function getXML(strXML As String, strElement As String) As String
-
On Error GoTo ErrHandler
-
If InStr(1, strXML, "<" & strElement & ">", vbTextCompare) > 0 And InStr(1, strXML, "</" & strElement & ">", vbTextCompare) > 0 Then
-
'Found it
-
Dim intLeft As Integer
-
Dim intRight As Integer
-
intLeft = InStr(1, strXML, "<" & strElement & ">", vbTextCompare) + Len(strElement) + 2
-
intRight = InStr(1, strXML, "</" & strElement & ">", vbTextCompare)
-
getXML = Mid(strXML, intLeft, intRight - intLeft)
-
Else
-
-
GoTo badXML
-
End If
-
-
Exit Function
-
-
badXML:
-
MsgBox "An error occured while trying to retrieve XML information,probably due to bad tags" & vbNewLine & "Please contact TheSmileyOne"
-
Exit Function
-
-
ErrHandler:
-
MsgBox "An error occured while trying to retrieve XML information" & vbNewLine & "Please contact TheSmileyOne" & vbNewLine & "Error Number:" & Err.Number & vbNewLine & "Error Description:" & Err.Description, vbOKOnly + vbCritical
-
Err.Clear
-
Exit Function
-
End Function
So in the form you opened you could get the information from the OpenArgs like this: - Dim strType as string
-
dim lngID as long
-
strType=getxml(me.OpenArgs,"Type")
-
lngID=clng(getxml(me.openargs,"ID"))
Why do I do it this way? Well if you only have 1 or 2 arguments to pass in the openArgs its not that complicated, but sometimes I might have 4 or 5, and then I simply find it easier to debug, when viewing a Openargs string that also indicates what each value represents.
Doh! I always forget The () on the end until I get an error...
I didn't realise OpenArgs stays in the memory, so its a lot easier than I originally thought.
Ta very much!!
NeoPa 32,556
Recognized Expert Moderator MVP
James, an important point to remember when perpetuating data across multiple records, or even just perpetuating any data into a new record, is to use the .DefaultValue property, rather than the .Value property. They can both be made to work, it's true, but you get far fewer problems and issues when done using the .DefaultValue property.
PS. Smiley, I like your thinking about the XML thing. I tend to use Split()/Join() array structures myself, but I might look into the XML thing a little more deeply now you've posted this.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Craig Brown |
last post by:
I would like to open selected (Filtered) records in a form. I
currnetly have a custom menu but would like to only open certain
records from i.e
Button 1 will open Site 1
Button 2 will open...
|
by: jean.ockert |
last post by:
Greetings.
Access version 2003 on an XP system
I am using the template "Event Management" database as the primary
database and need additional functionality added. I have a dance
studio. ...
|
by: Bob Sanderson |
last post by:
I am trying to create a form for a MySQL database similar to a spreadsheet.
The idea is to display a list of records, with the last line of the list
being an input form. When the user enters data...
|
by: NumberCruncher |
last post by:
Hi All,
I am struggling with setting up my first system of tables, forms,and reports, and could use your help!
I am setting up a database to keep track of the production of a produced item. The...
|
by: TheDataGuy |
last post by:
Using MS ACCESS 2002
I developed a FORM, and within that FORM, I created and added a SEARCH BUTTON, and then I created a SUB-FORM, so that when an the END USER clicks on the FORM it will POP-UP...
| |
by: dbnut |
last post by:
• I am using Access Trial 2007 in 2003 Mode.
• I designed a Form to track what tickets still need to be issued
using a split form:
________________________________________
Ticket 14 ...
|
by: BD |
last post by:
I am coding with C# in Visual Studio 2005 for a database application
residing on remote MS SQL Server 2005. What I want to do is open the
same form but from 2 different places and only one...
|
by: Birky |
last post by:
I am truly stuck and need some help on how to put this form together; any help or suggestions you can provide would be greatly appreciated. (Sorry this one is so long but I believe it is necessary to...
|
by: Dave |
last post by:
On my form I have combo boxes. These combo boxes, after updating
them, populate respective listboxes that are located below the combo
boxes on the same form. I am trying to use a "generate...
|
by: nomvula |
last post by:
hi guys
i need some help to duplicate records on my form datasheet:
here's the example of my form results:
ClientLookup DateCaptured ForecastDate Description ForecastQuantity Forecast Actual
UJ...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| | |