Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Records added from form into a recordset 1

Status
Not open for further replies.

StormcrowRahl

IS-IT--Management
Feb 13, 2006
9
US
Is it possible to group all records entered into a recordset or would it be easier to just create a seperate table and do an update query afterward?
 
Please explain more clearly. It is difficult to interpret what you want to do.
 
to group all records entered into a recordset". What do you mean? As new records are inputted, place them in a recordset??
"create a seperate table and do an update query afterward".
Do you mean an append query?
What exactly do you want to do? You didn't present to clearly.
 
Sorry for not being more clear. I'm wanting to trap all the records inputed via a form into a recordset. I want to do this because I want to generate a report with only the records the user entered during the current session. So when the user exits the form, the recordset is cleared. Is this enough information?
 
I'm also wondering if this is possible if two users are entering data via the same form at the same time. Is it possible to create seperate recordsets for each user? So that when each user is done, and they print the report, it will show only the records that they added.
 
How are ya StormcrowRahl . . .

Perhaps if you [blue]give an explicit example[/blue] of what your after . . . the light will shine thru!

Calvin.gif
See Ya! . . . . . .
 
Is this a split Front End / Back End application? If not it should be. You do not need seperate recordsets, but you need to tag the records with a Session ID and a PersonID. Then you have queries filtered on Session ID and PersonID. If you implement security you can use the 'CurrentUser' property.
 
There is probably an easier way, but if you are not using user level security, this uses the API to get the users login. You can then use this function as a default value on a form to fill in the user ID.
Code:
    Declare Function WNetGetUser Lib "mpr.dll" _
         Alias "WNetGetUserA" (ByVal lpName As String, _
         ByVal lpUserName As String, lpnLength As Long) As Long

    Const NoError = 0                    'The Function call was successful

    Function GetUserName() As String
         Dim LUserName As String
         Const lpnLength As Integer = 255
         Dim status As Integer
         Dim lpName
         ' Assign the buffer size constant to lpUserName.
         LUserName = Space$(lpnLength + 1)
         ' Get the log-on name of the person using product.
         status = WNetGetUser(lpName, LUserName, lpnLength)
         ' See whether error occurred.
         If status = NoError Then
              ' This line removes the null character. Strings in C are null-
              ' terminated. Strings in Visual Basic are not null-terminated.
              ' The null character must be removed from the C strings to be used
              ' cleanly in Visual Basic.
              LUserName = Left$(LUserName, InStr(LUserName, Chr(0)) - 1)
         Else
              ' An error occurred.
              MsgBox "Unable to get the name."
              End
         End If
         GetUserName = LUserName
    End Function
 
Okay, I get using the CurrentUser() function to pass that information into the report, but I can't seem to find anything on how to define or even use the SessionID. Any help would be great.
 
I am not really sure what defines a session, but I would simply define a public variable "mDtmSessionTime" that is the time the sessions starts.

Code:
  public mDtmSessionTime as date
   
  Public function getSessionTime() as date
     getSessionTime = mDtmSessionTime
  end function

now somewhere at the beginning of the session, maybe opening the data entry form.
Code:
  mDtmSessionTime = date()

Now on the data entry form you can set the control source of the User Tag and Session Time Tag fields and you could hide these controls.

txtBxSessionTime (field dtmSessionTimeTag)
= getSessionTime()

txtBxUser
= getUserName() (field strUserNameTag)

 
One more thing. In the queries the criteria of the query uses these same functions. Basically producing a where statement

WHERE dtSessionTimeTag = getSessionTime AND strUserNameTag = getUserName
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top