Passing Variables Between Forms In Shared Mode
Sep 28, 2006
Before I go any further w/this current application, I want to make sure this will work.
I have an access database w/a few forms that will sit on a shared drive on a network. Each user will also have their own username and password because each user will have a certain level of access to what they are allowed to see. The problem I am facing is that if I put the users ID into the global variables module, and two users log on at the same time, then access seems to somehow use both of the IDs when running queries. This makes sense that all uses can see it, since it's Global... but I need a way for simultaneous users to have a persistant unique id so I can query data that's only meant for them. I found this example of code that might remedy the situation by passing variables between the forms.
Call the code below in frmOne to pass the variable.
DoCmd.OpenForm "frmTwo", acNormal, , , , acWindowNormal, "Count=2"
Call the code below in frmTwo to get the variable.
Dim i as Integer
i = CInt(GetTagFromArg(Me.OpenArgs, "Count" ))
Will I end up w/the same result? Will all users be able to see this variable as well?
View Replies
ADVERTISEMENT
Apr 11, 2006
Hi, I am writing a script which will retrieve all of the tracks relating to whichever cd the user has chosen. The script is being written in asp and the line which sends the variable to access looks a bit like this:
sqlQuery3 = "up_getAlbumTrackInfo " & productID
Set rs3 = dbConn.Execute(sqlQuery3)
If possible could you tell me how to retrieve this value from access as I have become lost.
At present the SQL code in the query looks like this
SELECT tblTracks.trackName, tblTracks.TrackNumber FROM tblTracks
WHERE tblTracks.productID = (** variable would go here **)
Many Thanks
Tim
View 1 Replies
View Related
Nov 20, 2007
I'm into one of the subforms that will be using the public variable from the main form and am not having success passing the data from the main form over. on the subform, i created a textbox (txt_currentyear) w/ this in the control source field: =[WrkYear] & " Golf Outing"
WrkYear was the defined in a module as:
**********
Option Compare Database
Option Explicit
Public WrkYear As String
**********
I have created a listbox w/ a few years in it (current_year_listbox). this has =[WrkYear]=Me.Current_Year_listbox.Value in the after update field. i loaded the main form, selected the year, went into the subform to see if it passed the data along w/ no luck.
do i need to call or reference that module in every form or report before i can use the data from it? right now, i just get an empty field on the subform.
View 5 Replies
View Related
Dec 8, 2005
I can't seem to get the following code to work.
Any help would be appreciated:
Public Function NonConform(strProduct, strBatch As String)
On Error GoTo HandleErr
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmProductNonConforming"
stLinkCriteria = "[ProductName]=" & "'" & strProduct & "'"
stLinkCriteria = stLinkCriteria & "AND [BatchNum]=" & "'" & strBatch & "'"
DoCmd.OpenForm stDocName, , , (stLinkCriteria)
HandleErr:
MsgBox "Error in NonConform Function : " & Err.Description
Resume Next
End Function
View 1 Replies
View Related
Jan 13, 2014
I have a public sub routine which requires parameters to be passed to it when I call it from an access form. When I try to enter the code to call the sub I get a compile error. I've also tried calling it from another sub in the same module but get the same compile error - see below.
Code:
Sub EmailData(Datafile As String, To_mail As String, CC_mail As String, Subject_mail As String)
'code to use variables passed in
End Sub
[Code]....
View 4 Replies
View Related
Jul 9, 2014
I wrote this module
Option Compare Database
Option Explicit
Public Function OdometerInput(varodometer As Variant) As Long
Dim varKilometres As Variant
varKilometres = varodometer * 1.609344
OdometerInput = CLng(varKilometres)
End Function
It works fine in the immediate window (although I haven't just fathomed what to do with null values and such) But my question which I am sure will be 'easy when you know' is how do I pass the variable to it from a text box on a form and retrieve the data in another text box on a form.
View 4 Replies
View Related
May 29, 2015
I have never tried passing variables while calling a function so I don't know what the heck I'm doing. I'll give a simplified example of what I'm trying to do. The second variable vRank is reporting properly but the first one vID gets "stuck" on whatever the first item in the listbox is.
Code:
Dim vrt As Variant
Dim upSQL As String
For vrt = 0 To Me.List1.ListCount - 1
If Me.List1.Selected(vrt) = True Then
Call ChangeUp(Me.List1.Column(0, vrt), Me.List1.Column(1, vrt))
[Code] ....
View 3 Replies
View Related
Feb 25, 2014
My problem is as follows, i have created a report that calculates the total volume of FSC Materials. The user picks two dates from Calender controls that the report will range from. However the needs have now changed and i am required to make the report filter further based on user input, the problem i'm facing is that i cannot figure out a way to pass values from different variables to the report separate from another here is the code i would usually use to pass data to a query/report:
Code:
Private Sub MonthlyFSC_Click()
Msg = MsgBox("Select the Start and Finish Dates you wish to Query.", , "Start / Finish")
Start = adhDoCalendar()
Finish = adhDoCalendar()
[Code] ....
However i am now trying to do this, but it gives me an error as it is trying to pass the values to one field:
Code:
Msg = MsgBox("Select the Start and Finish Dates you wish to Query.", , "Start / Finish")
Start = adhDoCalendar()
Finish = adhDoCalendar()
sql1 = "[ORDER DATE]<#" & Format(Finish, "MM/DD/YY") & "#"
sql2 = "[ORDER DATE]>#" & Format(Start, "MM/DD/YY") & "#"
[code]....
It is performing incorrectly within the case select and passing the wrong criteria, as it will only display results that meet the default values' criteria. However the date criteria is not be passed either.
View 4 Replies
View Related
Sep 29, 2014
Access 2010 vba - I'm trying to pass a start date and end date to a date field in a make table query, and use the 'between' operator on that date field.
So I have a criteria on the date field like this "Between [dtStart] and [dtEnd]" and if I run the query manually it asks for 2 values and then works fine.
Here's the code I'm trying to run:-
Set qdef = db.QueryDefs("qryTest")
qdef.Parameters("dtStart") = StartDate1
qdef.Parameters("dtEnd") = EndDate1
Set rs1 = qdef.OpenRecordset(dbOpenDynaset, dbSeeChanges)
and I get the error "3219 Invalid Operation" on the last line.
View 2 Replies
View Related
Sep 22, 2014
I have several subform tabs and one that I have updated no longer shows up when I run the form on Form mode. The tab is there but no content or details of the subform
View 3 Replies
View Related
May 30, 2013
I have a subform that I use on two parent forms. The subform has a cascading combo box. The LocationID field gets filtered after CompanyID (named: cboCompanies) is updated. The problem is that I can only get the combo box to work on one form (Contacts_All). When I open the second form (Contacts_Clients), it asks for the Parameter Value.I am entering this into the criteria for the LocationID field:
[Forms]![Contacts_All]![SUBFRMContactsCompanies]![cboCompanies] Or [Forms]![Contacts_Clients]![SUBFRMContactsCompanies]![cboCompanies]
So, the "Or" is not working.Do I need to make a separate subform for each parent form or is there some way to get this working? I already feel as if I am managing way too many forms and need to simplify.
View 1 Replies
View Related
Mar 28, 2015
There are 2 mainforms and both of them share a subform. This subform is an add subform and I want the mainform to be refreshed after the data entry.Prior to the sharing, I had it coded it the way below and it works fine
Code:
Forms!frmMainformnoproc!frmActiveTasks.Requery
How would I recode this requery when it shared between 2 forms. frmMainformnoproc is the name of one of the main forms.The code above was present after an update was completed in the subform. Maybe I should be doing it after I close the subform and refresh the mainform. Based on that line of thinking I tried to add the code in the Activate event / Got Focus event of the mainform but the form did not get refreshed.
View 13 Replies
View Related
Nov 9, 2014
I have recently been experimenting with adding an Access database to a shared folder (in a network HomeGroup) and have it working on two networked PCs. Then tried the same with the database split but I get a path error on the PC joined to the HomeGroup (where the database resides) whenever the backend (tables) are accessed by a form or from the Tables listing. If I however open the backend file directly from the file directory, the tables all open as expected.
The path stated as being invalid in the error message starts with "C:Usersetc..... instead of LAF-PCUsersetc..... so it looks (to me at least) that it is attempting to load the file from the local hard drive rather than the host computer.
Why a split database works differently in this situation than a non-split.
View 13 Replies
View Related
May 29, 2013
For my database, I would like a picture as my background but I don't know if I should use embedded or shared?
View 2 Replies
View Related
Aug 7, 2014
the forms are not opening in modal/dialog mode when they should be.The forms' pop-up and modal properties are set to "yes"..The code specifies to open Dialog so, for example:
Code:
DoCmd.OpenForm "frmCompanies", , , , , acDialog
Yet, the form opens behind the other form (which, incidentally, is also set to be pop up and modal in the form properties--is that the problem? If so, why wasn't this an issue until now?).
View 14 Replies
View Related
Jan 13, 2014
I need to get an average of 2 variables eg.
target low eg 4
target high eg 8
target (to have the avg) result 6
I have been doing the following but dont work ..
=Avg([Target Low].[Target High]) result #error
=Avg([Target Low]+[Target High]) result 12
=Avg([Target Low]&[Target High]) result 48
=Avg([Target Low]:[Target High]) will not work
View 1 Replies
View Related
Jan 17, 2006
Hello!
I Have a
project form
test form
sample form
for 1 project there are n tests and for 1 test there are n samples.
The project form is alone and has a button to open the related tests in the test form. The test form incorporates the sample form as a subform.
What works:
For entries already in the database when I click the related tests button on the project form it opens the test form filtered in the correct manner.
For the test form the sample form displays and increments correctly.
What doesn't work:
When I open the project form in add mode I fill in the data and when it is done I click the related tests button and the linked/child field isn't there! No data, I can't get it to work...
Can you suggest something?
PS I cannot find anywhere in the Data properties the Linked field properties... neither child nor parent?
View 4 Replies
View Related
Jan 9, 2015
I have a form which was locked down (ie Allow additions, allow edit and allow deletions were all set to no) on the Form property. I want to change this to allow edits so in design mode I changed the Allow Edits property to Yes.
I then went to Form view and was able to update fields on the form. When I exited the form it asked me if I wanted to save the changes so I clicked yes.
On going back into the form I can no longer update the fields I could before. Going into design mode I can see that Allow edits on the form property is set to no again.
What is happening here. There is nothing in the on load or other events to set this to no, besides this shouldn't change the form property should it?
I know I can get around it my setting the property in the form itself but why is the property getting reset in the first place.
Access 2010.
View 11 Replies
View Related
Jun 26, 2007
Is it possible to access the values on one form and use them on another? For example, I have heard that the code might look something like this:
Form1.Text1.Text
When I've tried this, it doesn't work. Someone mentioned something about declaring them as Public, but they're not variables, they're actual record values on another form. Any suggestions?
Thanks!
Mike
View 8 Replies
View Related
Oct 10, 2014
I don't know, I have noticed that the SETVALUE argument is not openly available in the lookup tables when setting a macro. (But that aside) I have set my drives c: and d: as trusted, and also thicked the sub folder option.
View 7 Replies
View Related
Sep 30, 2013
I have a simple date stamp that works great in a private sub within a form. (error handling removed for clarity)
Code:
Private Sub btnDateStamp_Click()
' UserInit is global variable
Me!Notes.SetFocus
Me!Notes = Chr$(13) & Date & " - " & Time() & " - " & UserInit & _
" -" & vbCrLf & Me!Notes
[code]...
I am rewriting it as Module function that is Called from various forms, to save space. The function receives the parameters varFormName and varControlName. I wish to write the results of the function back to a memo field on the form.I am stumped at the get go by the need to refer to the Forms controls with a full reference instead of the Me command.
Code:
Function DateStamp(varFormName As String, varMemoName As String)
'varInitials, varFormName, varMemoName are global variables
Forms!varFormName.Controls!varMemoName.SetFocus ' Error here
'Me!Notes = Chr$(13) & Date & " - " & Time() & " - " & varInitials & _
[code]...
how to refer to the forms control's with their full reference, from within the Module's function, the rest will fall into place.
View 3 Replies
View Related
Aug 31, 2013
I'm using Access 2007.
I have a customer table attached to a form.
I want to put a command button next to the customer's email address so that the user simply presses the button and Outlook will be started with the customer's email address automatically inserted from the table.
I am playing around with the Hyperlink Address function and whilst this seems to do what I want, I can't figure out how to get the customer's email address from the tabel and insert it......
View 13 Replies
View Related
Sep 2, 2013
I've inherited an Access 2010 database that needs tweaking. I have a form, let's call it CALLED_FORM, that is loaded from various places - ie there are quite a few places that do the following
DoCmd.OpenForm "CALLED_FORM", , , , , , coupleofarguments
This works great when called from most places but if it is called from 1 specific form there is a likelihood that some code is executed that shouldn't be.
So I want to be able to do the following
In CALLED_FORM I want to be able to skip some code if the previous form is say FORMX. For all other forms I want it executed. E.g.
If PREVFORM <> "FORMX" then
code
more code
even more code
End If
Is there a system variable for PREVFORM.
I know I can change coupleofarguments to threearguments and pass something over in that to show which form it has been called from but that is a bit difficult.
View 3 Replies
View Related
May 7, 2014
I have a form which uses a listbox to display a given record but when a user without edit rights opens the form in read only mode
Code:
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormreadOnly
The user is unable to use the listbox to select a record to view.
I have also tried opening the form in edit mode (acFormedit) and then setting the allowedits etc. to False
Code:
Me.Form.AllowAdditions = False
Me.Form.AllowDeletions = False
Me.Form.AllowEdits = False
But this didn't work either.
View 3 Replies
View Related
Mar 7, 2013
I have a button using a macro to open a form in Hidden mode. Then I have another button on another form to open this form that was hidden.
When I open the form, the form is virtually blank apart from the form caption name. But when I close this and press the button again the form opens as normal.
I do not understand why?
I was told that once you hide the form and when you open the form again, it should appear normal. Why do I get this blank form??? Only by hitting the button again then the form is normal....
View 13 Replies
View Related
May 28, 2015
I am going into the Form Design mode
Click in the subform
I then set tab order by selecting the box and moving the field up.
Looks correct and then I click okay.
The subform does not change.
I go back into design mode, click in subform and select tab order and it looks correct????
View 2 Replies
View Related