Calling A Function From A Form
Jun 7, 2012
I have created a module with a function that capitalizes the third letter in words that begin with "Mc". I have a table with the city field all uppercase letters. I created an update query that takes the field and correctly changes it. How you would go about tying this function to the textbox on the input form. So, if a user incorrectly enters "mccoy" in the City Field the function would be called and would automatically change it to "McCoy".
View Replies
ADVERTISEMENT
May 30, 2005
Dear All.
I have a visual basic function, placed in a module.
I need to call it from a form field, and pass a value to it and the function has to return a value.
I tried it but it doesn't work
the value I get on the field is " #Name? "
any help will be very appreciated.
Thanks!
CS.
View 8 Replies
View Related
Oct 2, 2004
I haev a report with 15 sub reports. I have to use Visual Basic to format the sub reports. I know how to do the formatting (see below) but what I would like to do is have one function (Public) that I can pass the subReport name to and have the formatting happen. This would be mush easier to maintain than copying the code below into on_print events of all 15 sub reports.
Has anyone done this and have an example??
Thanks
--------------------------------------------------------------------------------------
Private Sub GroupHeader0_Print(Cancel As Integer, PrintCount As Integer)
Dim widthOfBox, startLeftSide
startLeftSide = 0.017
widthOfBox = 0.21
Me.ScaleMode = 1
Me.ForeColor = 0
'Repeat the following line of code for each vertical line
' 1*1440 represents 1 inch
' Me.Line (0 * 1440, 0)-(0 * 1440, 14400) 'Draws line at Left Margin
Me.Line ((startLeftSide * 1440) + widthOfBox * 0 * 1440, 0)-((startLeftSide * 1440) + widthOfBox * 0 * 1440, 14400) 'Draws line at Left Margin
Me.Line ((startLeftSide * 1440) + widthOfBox * 1 * 1440, 0)-((startLeftSide * 1440) + widthOfBox * 1 * 1440, 14400) ' Draws next line
Me.Line ((startLeftSide * 1440) + widthOfBox * 2 * 1440, 0)-((startLeftSide * 1440) + widthOfBox * 2 * 1440, 14400) ' Draws next line
Me.Line ((startLeftSide * 1440) + widthOfBox * 3 * 1440, 0)-((startLeftSide * 1440) + widthOfBox * 3 * 1440, 14400) ' Draws next line
Me.Line ((startLeftSide * 1440) + widthOfBox * 4 * 1440, 0)-((startLeftSide * 1440) + widthOfBox * 4 * 1440, 14400) ' Draws next line
'the 14400 is an arbitrary number to increase the line to the max of a
'section.
End Sub
View 1 Replies
View Related
Jan 4, 2006
Is there a way to call a function stored in a module in the back-end access file from within a form in the front-end access file?
I want to be able to slip in a change to the code, and not have to then copy the changed module out to every front end file.
I am thinking that this is something that is in fact trivial to do, but for the life of me, I am drawing a blank on how to do it. Or even what search terms to use to search the help files.
Any help is appreciated.
Thanks,
David
View 3 Replies
View Related
Aug 10, 2013
I have 28 combo boxes on a form, which I want to insert data into the table as they are changed. Each one will pass the same sets of data just with different parameters which come from the form.
Rather than putting the same code to insert on each of the 28 combo boxes I thought it would be easier to create a function to do it and pass the parameters to it through a sub on the AfterUPdate event of the combo box.
I need to pass 4 parameters, if I only put 1 in there it works fine, but when I start putting more in it doesnt work and I get compile errors or syntax errors.
Sub routine:
Code:
Private Sub cboMonday1_AfterUpdate()
If Me.cboMonday1 = 1 Then
Me.cboMonday1.BackColor = vbGreen
Me.cboMonday1.ForeColor = vbBlack
[Code] .....
View 9 Replies
View Related
Oct 5, 2005
My title may not accurately express my question. If you can suggest a better way to do this, please feel free to elaborate.
Within Access, I have an "Invoice Number" table, with a single field containing a number. I have a function that accesses the table, increments the number and returns it to the invoice number field.
I need a way to perform this same function to the same table from within WORD.
I appreciate your time and interest.
View 1 Replies
View Related
Dec 1, 2005
Hi,
In the query field i am putting: -
Consecutive Months: Query_Month_Consecutive([Report_2_group_data].[Availability], array([Monthly_availability_CT].[12],[Monthly_availability_CT].[11],[Monthly_availability_CT].[10],[Monthly_availability_CT].[9],[Monthly_availability_CT].[8],[Monthly_availability_CT].[7],[Monthly_availability_CT].[6],[Monthly_availability_CT].[5],[Monthly_availability_CT].[4],[Monthly_availability_CT].[3],[Monthly_availability_CT].[2],[Monthly_availability_CT].[1]))
Basicly the values of them fields are entered into the query, all fields exist and everything is ok.
Anyhow the function is not loaded, i have tested with a simple msgbox and it does not do it.
However when i simply do
Consecutive Months: Query_Month_Consecutive([Report_2_group_data].[Availability], Monthly_availability_CT].[12)
It works and the msg box appears?
I really need it to be an array for what im doing any help would be great
Thanks
k0r54
View 3 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
Dec 23, 2013
I have the following function that I found online. Unfortunately I can't remember where I got it since I've had it for a little while. Today, when I tried to actually put it to use it didn't work.
I'm calling it from a form as follows: CompactDB (tblHotword)
tblHotword is just a random table from the back end. My understanding of the function was that it would use that table to connect and get the file name of the back end.
Whenever I run it, Access pops up a window that says "Object required" and nothing else. It doesn't look like a standard error message popup. When I click 'OK', Access continues with the rest of the code as if nothing went wrong. The function doesn't run though.
Code:
Public Function CompactDB(TableName As String) As Boolean
On Error GoTo Err_CompactDB
Dim stFileName
DoCmd.Hourglass True
stFileName = db.TableDefs(TableName).Connect
[code]....
View 8 Replies
View Related
Oct 4, 2005
I need help...
ok, what i have is a table with all the fields, comp_id, Yr,Values
i need to put 2 combo boxes coz the user needs to choose bet. 2 years and get the difference of the value within each yr. I got this part already but my problem is, i need to do a report and what i need to do is everytime the user chooses 2 yrs. the report should come up showing the difference of 2 yrs and the comp_id and type under each yr plus the difference of there values.
*note i already did the whole report including yr, comp_id,data_type*
Im just having a problem in the form structure..
am i exmplaing this clearly?
Pls help..thanks
View 1 Replies
View Related
May 22, 2006
Hi All
I have a form based on a table called tblListMaster and I want to allow users to open up another form showing all the members of one of the entries in that table so I have added a button called 'Show List Members'.
The list members form which I then want to bring up is also based on tblListMembers (it's a master-detail form). When I hit the button to open up the list members form I get an error message saying that the table is already opened exclusively.
I can understand why I get that message so I thought I would be cunning and create a dummy form which I open up, passing in my list id in the openargs (at that point I also close the original form) and then from that dummy form automatically open up the master detail form and close the dummy.
Code in List Master form
Private Sub cmdListMembers_Click()
' open up the list members form
DoCmd.OpenForm "frmDummy", acNormal, , , , , Me.ListId
DoCmd.Close
End Sub
Code in Form Load of dummy form
Private Sub Form_Load()
DoCmd.OpenForm "frmMaintainListMembers", acNormal, , , , acWindowNormal, Me.OpenArgs
DoCmd.Close
End Sub
Sadly I still get the same error message - does any one have any ideas what I'm doing wrong?
Gordon
View 4 Replies
View Related
Jul 27, 2005
How do you use a button on a form to call another access program? We have 8 access programs that we want to be able to call from one form.
Thanks
View 2 Replies
View Related
Mar 21, 2006
Hi. I have spent ages searching, but I can't find anything relating specifically to what I want to do, and I'm simply not experienced enough to make up the code as I go along.
I want to call a value from a field in TableA to a textbox on a form bound to TableB. I know, its probably simple, but I can't figure it out.
Any help would be greatly appreciated.
View 13 Replies
View Related
Sep 27, 2006
I have a main form with a subform. I need to update values in the subform when a field on the main form is updated using afterupdate on that control.
Example:
main form name: mainform
control name: gst (on main form)
subform name: subform
records displayed as datasheet.
records field to update: retail
In main form gst control afterupdate event:
Me.[subform].[Form].retail_afterUpdate
Hoping to call the afterUpdate procedure on the retail field.
Error message:
Method or data member not found.
View 2 Replies
View Related
Apr 20, 2015
I want to call the "On Current" event of another form.
I have a parent(mainform) form and then I have a subform(CurrentForm) and in that subform(CurrentForm) I have another subform(mysubtab01). From the mySubTab01, I want to call the On Current of the parent form. How can i do this?
This is an example of how I am setting the record source of the deepest subform where I want to call the parent on current from:
Forms(mainform)(CurrentForm)(mySubTab01).Form.Reco rdSource = "Select * from subQrytab03"
View 12 Replies
View Related
Apr 21, 2015
I have Form A that is bound to tbl_Member (MemberId, LastName, FirstName, and some other fields).
On Form A is a combobox [cbo_Selector]. The combobox shows LastName and FirstName from tbl_Member, but when a name is selected, it returns the member's ID to Form A and causes that member's record to show in Form A (along with other data pertinent to the member). This works fine until I type a name into the combobox that does not exist in the underlying table.
I use the NotInList event of the combobox to pop up another form (Form B) in the DataEntry mode. Form B is bound to the same table as Form A. I enter the LastName, FirstName, and exit Form B. What I am trying to do is to have Form B pass back the new MemberId to Form A and specifically to add that record's data to the combobox on Form A.
I have tried several things to accomplish this. When Form B updates, the table has the new member added, but when I try to requery Form A or the combobox, I get errors. how do I communicate to the combobox in Form A the information from the newly added record?
View 11 Replies
View Related
Jun 24, 2014
I am using an on-click event on my form to call up a report for the current record. It has been a while since I've used the form to call the report, but I always remember it working correctly. Today when I try to call up the report, it opens but no record is being pulled up so the report pulls up blank.
Code:
DoCmd.OpenReport "rptSupplierInformation", acViewPreview, , "[OperationID]=" & [cboMoveTo], acWindowNormal
View 1 Replies
View Related
Feb 9, 2014
I have created a custom message box form that suits my needs for this particular situation. It is called (opened) in the middle of a bunch of other VBA procedures. What I am having a problem with is how do I "pause" the rest of the code from running after the message box call?
For example, with a regular msgbox() function, once called, the code will wait for the user input or click of a button, then continue. My problem is that I am using the basic docmd.openform procedure, and it opens the message box form just fine, but then continues on with the rest of the code after the form is opened.
How would I "pause" the code after the call of opening my custom message box form, then continue it after the user clicks one of my closing buttons from that form?
Furthermore, although its not entirely needed in this situation, for future reference, how would I have that message box form return a value to the calling procedure?
View 14 Replies
View Related
Dec 2, 2014
So Access was unable to manage the amount of content that I needed to produce in a single report. The reports contain 12 charts/graphs all of which I needed on separate pages (one chart per page). As such I could not create large enough charts in access to fit to each page, as Access limits the amount of space one can use in a report.
I downloaded Microsoft Reports Builder 3.0 and built my reports as needed and can generate them as desired at current. I'm wondering if there a way to call that RDL file I created to generate my reports from a form control button in Access?
View 3 Replies
View Related
Jun 22, 2005
This is my first time using access and got it to work for a blank database.
The problem I ran into is how do I call for the form in the database from my desktop
I tried a shortcut but it does bring it up but i still have to click on the form to open it
Is there a way to make a shortcut on my desktop to open the form
THXS Steve
View 4 Replies
View Related
Jul 13, 2006
Hi. I am creating a contact management database. Also I am new to Microsoft Access. How would I create a calling history record for each of the clients in the contact database? What would be the best way and how would I go about it? The calling history ideally would include the call recipient, time, date, subject and notes. Thanks. Take care.
View 1 Replies
View Related
Jun 19, 2005
Hi All
Nice to find a forum which helps ppl new to VB access 'like me' :). I appreciate any help in this regard.
I generated a report from a query. I would like to modify this report by adding parameters pertaining to 'another' query (say query num 2). There is no relationship between these two queries. How do I call the 'other' query (query num 2) thru VBA and modify its parameters.
Thanks alot in advance
View 1 Replies
View Related
Jun 30, 2005
I have a series of IF statements that check my fields and if null call a message telling the user a value must be filled in before the record cab be saved. The code works fine. Here is the code for two fields to show the syntax:
If Len(Me.FName.Value & "") = 0 Then
MsgBox "You must enter a value into FName."
Me.FName.SetFocus
ElseIf Len(Me.LName.Value & "") = 0 Then
MsgBox "You must enter a value into LName."
Me.LName.SetFocus
This same code repeats for each field.
Here is my problem. I have Home, Work and Cell phone fields. The client may not have these numbers. I want to add code that add code for these fields that calls a message box with 2 command buttons(yes & no) with the Message" Does the client have a Home Phone?"
The user would choose the yes or no command button. If the user chooses yes then the same code as above would be called. if he chooses no the ElseIf statement would be called. Can this be done? I don;t know how to wriye the code for the command buttons. can anyone help?
View 14 Replies
View Related
Jan 26, 2006
Hi,
I'm having problems calling a simple query from the VBA associated with one of my forms. The code goes thus:
Private Sub Form_Current()
Dim rs As Recordset
Dim db As Database
Dim qryMaxAlp As QueryDef
If Me.NewRecord = True Then
'query database here and find out next alp_key
Set db = DBEngine.Workspaces(0).Databases(0)
Set qryMaxAlp = db.QueryDefs("qryMaxAlpKey")
Set rs = qryMaxAlp.OpenRecordset()
Else
End If
End Sub
The problem occurs on Set qryMaxAlp = db.QueryDefs("qryMaxAlpKey") where I get the error "3265 Item not found in this collection". However the query does exist, and when I run it independantly works fine (it brings back the maximum primary key of a linked table.
So, what am I missing?
View 2 Replies
View Related
May 4, 2006
Hello.
I have a database that runs a fews tasks for me me when no one is in the office as the systems are quicker and the admin work tedeous and boring, yet necessay. The problem Im having is in calling a database. The problem stems, i think, from the names on the folder. Unfortunately renaming isnt an option because its got many hundreds of users on the server and I dont have the admin rights besides.
The error is coming on .......
Call Shell("msaccess u: eam-shared-dataRes. SalesOutsourceOutsource_DbsDatabase_StoreOutso urce.mdb").
The error message I get says that u: eam.mdb isnt valid .... when its not. The error is caused presumably by the " - 's " and probable after it passes this the " Res. Sales" will cause an error too. So my question Im asking is, is there anyway to make the path read in full, I've tried preceeding with < and ending with > and "" or even ' but still no joy. Can anyone please help, its getting annoying now. :o :confused:
View 5 Replies
View Related
Oct 21, 2006
Hello, I have a VBScript that when clicked on opens the command prompt and fires code to upload a query to my website.
What I would like to do is place a command button on my form that will call the script to run instead of having to go and click on it.
I have searched, maybe using wrong terms, but havent been able to get the right code to do this
any help to call this script from a command button would be appreciated.
View 2 Replies
View Related