Force Control To Update ?

Jul 24, 2006

Can I force a control to update (ie run its after update event code) from a global module.



Thanks.

View Replies


ADVERTISEMENT

Force Update Into Unbounded Comments Field

Oct 24, 2005

Hopefully there's someone who can help me with this!!! I've had several unsuccesfull attempts and don't know what else to try...

We're trying to force users to make entries in a field called txtComments in the frmQuestionnaire form if they provide negative responses and to stay on that record until the comments are changed. Inside the form is an option group (fraResponses) which contains options (OptA, OptB..etc.) valued from 1 through 7, based on a likert 7 scale. We're only using a likert 6 scale, so the respondents will only see 2-7 on the form. If they options B-D (valued 2-4), they are considered negative, so we want to make sure they enter a comment.

I tried to enter the italicized code under the form on BeforeUpdate, AfterUpdate, CmdUp (click to next question) and CmdDown (click to previous question), with frmQuestionnaire but nothing happens:

There is a module called clsUser which contains the following and where I tried to insert the code:

Set myForm = Forms!frmQuestionnaire
' ================================================== ==
' First, set the value of the variables
' ================================================== ==
lngQuestion = arrQ(lngArray, 0)
lngSession = GetCustomInfo("TestSession")
lngUser = UserID
lngBillet = BilletID

strComment = Nz(myForm.txtComment, "")

strComment = "None"

'If user selects negative responses
If Form_frmQuestionnaire.fraResponses.OptionValue = 2 Or 3 Or 4 And strComment = "None" Then
MsgBox "Please explain the problems you encountered with the system which " & _
"caused you to select an unfavorable response."
Form_frmQuestionnaire.txtComment.SetFocus

End If

lngResponse = myForm.fraResponses


When I place the code there, the dialog box appears for all values and goes to the next record. This is what appears for the CmdUp (click to next question):

If cUser.blnDirty = False And Me.fraResponses = 153 (this is default value for the entire option group) And cUser.blnNew = True Then
cUser.blnDirty = True
End If

cUser.CaptureAnswer
If cUser.lngArray < cUser.UBound_ArrQ() Then
cUser.lngArray = cUser.lngArray + 1
Else
cUser.lngArray = cUser.UBound_ArrQ()
End If
cUser.FillQuestions
cUser.blnDirty = False

I've tried to enter the line of code with the form and the module, but no luck.

I also want it to remain on the same record until the field is changed. The form is unbound and has the following:

Public Sub FillQuestions()


'************************************************* ****
' Purpose: Scroll through the questions
'
' Assumptions: N/A
'
' Effects: N/A
'
' Inputs:
' None
'
' Returns:
' None
'************************************************* ****

Dim lngRG As Long

Set myForm = Forms!frmQuestionnaire
myForm.txtQuestion = arrQ(lngArray, 1)
lngRG = arrQ(lngArray, 2)
myForm.prgProgress.Value = lngArray + 1
myForm.lblProgText.Caption = "Question " & (lngArray + 1) & " of " & lngQuestions
myForm.lblTS.Caption = "Test Session: " & arrQ(lngArray, 3)
myForm.lblQID.Caption = "Question ID: " & arrQ(lngArray, 0)

GetResponseSet lngRG
FillAnswers
If lngArray = 0 Then
myForm.txtComment.SetFocus
myForm.cmdDown.Enabled = False
Else
myForm.cmdDown.Enabled = True
End If

If lngArray >= UBound(arrQ) Then
myForm.txtComment.SetFocus
myForm.cmdUp.Enabled = False
Else
myForm.cmdUp.Enabled = True
End If
End Sub

Public Sub FillAnswers()
'************************************************* ****
' Purpose: Fill out the user's previous responses
'
' Assumptions: N/A
'
' Effects: N/A
'
' Inputs:
' None
'
' Returns:
' None
'************************************************* ****

Dim strSQL As String
Dim recAnswer As New ADODB.Recordset

Set myForm = Forms!frmQuestionnaire
strSQL = "SELECT datResponse.reDatQuestionID, datResponse.reDatRespondentID, "
strSQL = strSQL & "datResponse.reDatResponseSetID, datResponse.reComment "
strSQL = strSQL & "FROM datResponse "
strSQL = strSQL & "WHERE datResponse.reDatQuestionID=" & arrQ(lngArray, 0)
strSQL = strSQL & "AND datResponse.reDatRespondentID=" & UserID

recAnswer.Open strSQL, CurrentProject.Connection, adOpenForwardOnly, adLockOptimistic

If Not recAnswer.EOF Then
myForm.fraResponses = recAnswer!reDatResponseSetID
myForm.txtComment = recAnswer!reComment
blnNew = False
Else
If myForm.fraResponses <> 152 Then
myForm.fraResponses = 153
myForm.txtComment = ""
blnNew = True
End If
End If

recAnswer.Close
Set recAnswer = Nothing

End Sub

Thanks in advance for your help!!

View 1 Replies View Related

Forms :: Force Update Of Field Before Record Is Saved

Aug 1, 2013

How can I force a field in a form to be updated before the record is saved / changed?

For instance I have a form with information on it and I want to ensure that any time the form is updated the user fills in a section providing the date and by who it has been updated by. I dont want the record to save unless that information has been filled out, and I also want it to take you to the field if you press save and it hasnt been filled out along with an error message.

To try and be a bit clearer. At current I have a Save and New button. This saves the form if dirty and opens a new record.

I want to add in the step that if record has been changed and FieldA has not just been updated then go to fieldA (Showing a message box). If FieldA has just been updated then save record and open new as normal.

My current save & new button properties are as follows (in Macro Editor)

On error Go To Next
If [form].[dirty]
RunMenuCommand Command SaveRecord
End If
If [MacroError].[Number}< >0
Message =[MacroError].[Description]
Beep Yes
Type None
Stop macro
On Error
Go To Fail
Go To Record
Record New
Go To Control
Control name Resort Code

View 3 Replies View Related

Stock Control Update Query

Nov 21, 2007

basically, im making a stock control database

i've made an update query but its not exactly what i wanted
is there a way to make the criteria equal a particular form field because i dont want the user to type in the stock ref in a parameter query.

also, how do i make it so no orders can be made on stock which has stock levels of 0 and have a message saying it is out of stock
at the moment, i put >0 in the criteria underneath no in stock field in the update query

i hope i made it clear because im not sure how to explain it

thanks for any help
the jayman

View 4 Replies View Related

Problem With Auto Update Control

Jan 15, 2006

Hi.
I am new in using Access, so forgive me if the solution for my problem is easy.

I wrote for customers a little program, which receives data via RS-232 serial port and then place readed data into MS Access database. After i put the data into field in table (database, table and field are set in my program), there is some kind of script that continue the process of data manipulation.

The problem is, that customers want to activate that script automatically, when i place data in the field. So, i made a form, which contains bound control to this field. Every 2 seconds i am refreshing this form, so when i change the data in the table field, i can see the change in the form control. Now, how can i make the OnChange event to work, when the data changes? I tried to do it, but nothing happens, except if i am writing from the keyboard something directly in the form.

Can this be done and if, how must i do it, so when a new data arrives to run automatically the client script?

Thank you in advance

View 3 Replies View Related

Update Automatically A List Control

Jan 5, 2005

hello all
i have a problem, i have a form bounded to a query
that displays the books infos, in this form i have a list control
that displays the list of authos based on the code of the book
the problem is when i have more than one record in the opened
form ie more than one book and i move to the second record
the list doesnt change and displays the authors of the first book
when the form first opened
anyone has an idea how can the list be updated automatically when
i move between records
thanks a lot

View 6 Replies View Related

Modules & VBA :: Set Focus On Control After Update

Jan 15, 2015

I have a continuous form populated with a pivot view from SQL. When I enter data in the form I send the data to SQL (ctrl after_update) and then re-populate the form. It works.

When I have entered data in a ctrl - then I have to bookmark the record so I can select it again (find_first). I can "save" the location of the control where I have entered data, but I want to select the location where the user has set focus - which triggered the ctrl after_update..My ctrl after_update looks like this:

Code:
txt_account = Me.Parent.txt_account_id.Value
txt_cost_center = Me.ActiveControl.Name
Call update_data_input(Me.ActiveControl.Value, Me.account_id.Value, Me.ActiveControl.Name)

[code]....

View 6 Replies View Related

Forms :: Update A Bound Control From Subform

May 3, 2013

I have a Main form with several sub forms on it the tables behind each form are related tables. The user enters data on the main form with the exception of one bound control then moves on to enter data on the sub forms On exiting the record or the main form I want to take data from several of the sub forms and add them together and enter result in the bound form on the main form. Because this bound control is not used to enter data in there are no event triggers to code to get this done.

View 3 Replies View Related

Forms :: Control Update Event Not Firing

Jul 4, 2014

On a form I have a pair of controls, Price and PriceInUSD. If the user enters a new value into the Price field, then its AfterUpdate event fires, which looks up the relevant exchange rate and updates the PriceInUSD control accordingly. That all works fine.

Now in some circumstances (if a checkbox elsewhere on the form is checked), I generate a modal dialog box asking the user to confirm that the Price value is correct, or enter a new value.

That modal dialogue box's Enter button's On Click event then updates the Price control before closing the dialog. That bit works fine, too - but I had thought that this update of the Price control would fire its AfterUpdate event - but it doesn't.

So, my basic question is : do Control events only fire in response to user input, and not to programmed changes ?

View 12 Replies View Related

Running A Update Stock Control Query From A Button

May 20, 2005

Hi

I am a relatively new user to access and wondered if you could help me with a stock control problem.

I have created an update query (qryUpdateQuantityinStock) with the below fields:

QuantityinStock
tblProduct
Update: [QuantityinStock]-Forms!frmCustomerOrder![frmProductOrderLine Subform].Form!Quantity

ProductNumber
tblPrdocut
Criteria: [Forms]![frmCustomerOrder]![frmProductOrderLine Subform].[Form]![ProductNumber]

When the user enters the quantity they require into the orders form I would like to deduct it from the quantityinstock field in the products table.

The above query does work if you add the following code to the beforeupdate event of the orders subform:
If Me.NewRecord Then
DoCmd.SetWarnings False
DoCmd.openquery "qryupdateQuantityinStock"
DoCmd. Setwarnings True
End If

Although I wanted the query to run from a button (confirm order) on the order form so that the user decides when to deduct the stock.

I cannot put a button onto the orders subfrom where the query should run from and if I place the code on a button on the main orders form it only deducts one order (one product) and not all products on the order.

Can you help me find a way to run the query from a button?

I have read through the threads and found lots of information on stock control, although have not yet found anything similar to this problem. I understand that this is not the correct way to do stock control, although my database is for academic purposes and only requires a simple stock control system.

Any help would be greatly appreciated (sorry for the long post!). :)

Many thanks

View 1 Replies View Related

Modules & VBA :: Update Value In Unbound Control Then Trigger Event?

Feb 4, 2015

I am updating a value in an unbound control on an unbound form. When the value in the control is changed I want a sequence of code to execute. Specifically changing the record source of a subform and refreshing it.

The problem I have is that when the value of the unbound text box is control is changed (I am using a button to change the value as a test) the after update event on the text box does not do anything.

I did a simple test using a button to change the value in the text box and in the afterupdate event of the text box asked it to output the value of the textbox to a message box as shown below.

The problem is this does not work, nothing happens. If I tab out of the text box or change the value with the keyboard however the msgbox appears. Just not via a vba change.

Code:
Private Sub Prod_ID_AfterUpdate()
Dim pid As String
pid = Me.Prod_ID
MsgBox pid
End Sub
Private Sub Button_Test_Click()
Me.Prod_ID.SetFocus
Me.Prod_ID = "TEST"
End Sub

View 7 Replies View Related

Forms :: Update Text Box Based On Input Of Date Control?

Feb 10, 2014

Can you update a text box on a form based on input of a date control? Here is what I have. I have several date controls on my form, and I want to update a status textbox based on which of these date boxes is filled out, but I need the status to be filled into the table as well. Do I update the field on the table, and then requery the text box? Is there some other method for accomplishing this?

View 9 Replies View Related

How To Force A One-to-many Relationship

Sep 23, 2005

I am using Access 2003.
Access front end, sybase backend. I am building the queries in the design mode in Access.
Here is my question...

I am looking for a way to force a one-to-many relationship between two tables. I am connecting the primary key in table1 to a field (foreign key) in table 2. But it keeps going to one-to-one.
It should be doing one-to-many (the "1" and the "8"-sideways infinity symbol).

What am i doing wrong? Please help.

View 14 Replies View Related

Nz Or IIf(is Null) To Force A Certain Value?

Jun 13, 2007

I have a query in Access 2000 that I can't get to force a certain value in empty rows for a particular field column - maybe someone here can see why?

The SQL for the query is as follows (give or take some)...:

TRANSFORM Count([Testing DB].[DB_ID]) AS [CountOfDB_ID]
SELECT [Testing DB].State, [Location].[North], Count([Testing DB].[DB_ID]) AS [Total Of DB_ID]
FROM [Testing DB] LEFT JOIN [Location] ON [Testing DB].[Address] = [Location].Address
WHERE ((([Location].[Size])=Nz([Size],"Big")) AND (([Testing DB].[Window Length]) Is Not Null)
GROUP BY [Testing DB].State, [Location].[Size]
ORDER BY [Testing DB].State, [Location].[Size]
PIVOT Format([Date],"mmm-yyyy");

I want my crosstab to end up so that any records in the "Size" column that are not matched between the two tables, and therefore come up empty for those rows in the query results, are forced to change from empty to "Big" - so that they can be added into the count of "Big" hits that the query ends up with in the "Size" column. But all my "nz" addition did was remove the columns with blank values from the crosstab - no addition to the "Big" counts.

Am I perhaps going about this incorrectly? Maybe I should have used some form of iif(is null) instead.:confused: Any help is, as always, much appreciated.

View 4 Replies View Related

Force ROW Heading In A Crosstab

Dec 7, 2005

Being an amateur at Access, I've only recently realized that you can force column headings for crosstab queries, by typing those headings into the properties of the field selected as the column. But can you do the same for ROWS?

My data concerns patients of a specific type and the times of day they show up at our A&E (ER). I've grouped these by hour and now I want to crosstab them by day of week. But if there aren't any between say 3am and 5am, those hours don't show in the query, which is screwing up a pre-formatted report I have.

I've found some assistance on other threads.....
http://www.access-programmers.co.uk/forums/showthread.php?t=92471
http://www.access-programmers.co.uk/forums/showthread.php?t=83820
.....but to be honest I didn't really follow it.

Is there an easy solution? If not, it's not a huge problem and I can "fudge" it once a month, offensive as that must sound to you professional types!

Thanks as always.

Pat

View 3 Replies View Related

Crosstab - How To Force A Record

Jan 31, 2007

If the query returns no results, like it should, but I want to force a row with zeroes in it, can that be done? how? i have tried an if statment in all the fields to fill something in if the field is null but that didnt work. i tried using nz but that didnt work. any suggestions would be appreciated! Thanks!

:confused:

View 1 Replies View Related

Force A Button Click

Feb 9, 2005

I have a form on which I have a button that I want the user to click after a cetrain field on that form is updated.
I display a little pop-up box saying to make sure that a user clicks on that button.
Is there a way to know that this button was clicked? Is there a way to not proceed with anything else until that button is actually clicked?

Thanks.

View 4 Replies View Related

Force Size Of Popup

Feb 24, 2005

Is there a way to force the size of a popup form? I want it to be around 3.5" by 4" because every time it popus up it is only around 2" by 1" and i have to resize it to look right.

View 1 Replies View Related

Run Report Force Printer

Apr 3, 2008

I have a button that I click and it gets a value from my form and opens a query linked to a report, grabs the records, populates the report, and previews the report.

What I want to do now is Run the Query, dont show it, but print it to a deisignated Printer.

1. How can I run the report, not show it, but print it?

2. How can I force a print to a specific printer on my network?


Thanks..

View 12 Replies View Related

Force Left Mouse Click

Jul 11, 2005

Hi,
Is there a way to force a left mouse click in VBA?

View 3 Replies View Related

Question About Force Shutdown The Database

Jan 22, 2007

I download the database from this thread http://www.access-programmers.co.uk/forums/showthread.php?t=103278 and I copy the table, form, macro and module to my database but and error is appearing showing that missing shutdownform.

Pls can any one help me.

View 1 Replies View Related

Random Autonumber Force Positive Only

Apr 1, 2007

I don't know if it's possible, but is there any way of forcing the random autonumber generator in tables to be a positive number only?

The autonumber as I've searched on the forum can be a positive or negative number and I'd like to use the random autonumber feature as a primary key for account numbers for my database, but not using the negative numbers as they will look like odd account numbers with the leading negative.

I could possibly remove the leading negative, but there's then the chance that you'll have duplicates.

Thank you!

View 1 Replies View Related

Force Cursor To Start Of Text Box?

May 6, 2005

Is it possible to force the cursor to move to the start of a text box when it gets the focus? (I suppose what I am really asking here is, is it possible to force a 'Home' key event?)

There is a text entry box, which when people put the cursor into it, it sometimes sits part the way in, consequently the operator could end up trying to type in more information than there is available space. I know that education might go along way here, but you just can't teach some people.

Tim

View 4 Replies View Related

How To Trap An Error (and Force A Choice)?

Dec 1, 2005

How do I programmatically force an error dialog to make a certain choice?

I'm able to trap the dialog via the following code:


Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 7787 Then 'record updated by another "user" (subform)
MsgBox "Error trapped!"
Response = acDataErrContinue
Else
Response = acDataErrDisplay
End If
End Sub


Problem is, if I bypass the 7787 error in this manner, it defaults to dropping the changes, rather than saving the record, which is what I want. (Both are choices on the dialog.)

Any help would be most appreciated.

View 7 Replies View Related

How To Force Someone To Use A Value In Listbox In Datasheet View?

Sep 22, 2006

This question seems so simple, I feel like the answer is right in front of me. However, I have no idea how to solve this problem.

Essentially, I have a field in a table (or data entry form in datasheet view) that looks up values from a different table. I want the user to only be able to use one of those values, not type in whatever he wants. How do I accomplish this?

View 8 Replies View Related

Forms :: Force Value In Unbound Combo Box?

Mar 26, 2013

Ive got a database with a combo box, called "combo1" (with 2 columns). It is unbound but uses a query as its row source. When i select a value in combo1 is places the data from combo1.column(1) into a textbox (text1). I then click the next record button (button1) and it then keeps the same value in combo1 because it is unbound. So i need it that when i go to the next record it displays the value in combo1 that relates to text1.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved