MS Access 2007 Continuous Form Alternate Back Colour Screen Corruption - ms-access-2007

There should be a simple solution to this but I can't find one:
I have a continuous form with all of the controls Enabled and Locked with transparent background and frames. the Form:Detail section has an Alternate Back Colour set.
The form displays transactions for a bank account selected via a combo box in the form header. When the bank account is changed the new account's transactions are displayed.
However, if the first on-screen row displayed for the new account isn't the same colour as that for the previous account then all of the controls retain the background colour of the previously displayed row. The same screen corruption occurs on Requery or if control goes to a particular row.
Hopefully the picture below will clarify:
Example of Alternate Back Colour problem
I've tried all sorts of things but nothing seems to solve this. The last resort is removing the alternate back colour but I really don't want to do that. Any help in resolving this would be greatly appreciated.

Despite having tried to put this out of my mind and get on with functional stuff, it has been niggling away constantly. After a great deal of searching and generally getting distracted, I've found a really simple solution ( at https://access-programmers.co.uk/forums/showthread.php?t=268390):
When I change accounts or go to a record, it is simply a matter of bracketing the record operation in an 'Echo False', 'Echo True' pair. So, for example:
If RecordsetClone.RecordCount > 0 Then
Me.RecordsetClone.MoveLast
If Me.RecordsetClone.RecordCount > wRowNum Then
wRecordNo = Me.RecordsetClone.RecordCount - wRowNum
Else
wRecordNo = Me.RecordsetClone.RecordCount
End If
Echo False
DoCmd.GoToRecord , , acGoTo, wRecordNo
Echo True
End If
or:
Set rs = Me.Recordset.Clone
rs.FindFirst "WkACT_ID = " & Nz(wCurrentRecord, 0)
If Not rs.EOF Then
Echo False
Me.Bookmark = rs.Bookmark
Echo True
End If
Hoorah! Hopefully that will be helpful to somebody stuck with the same cosmetic, though infuriating, problem.

Related

Disallowing textbox editing if a ComboBox in the same Form is not filled (for each row individually) [duplicate]

I am working on an Access 2010 form which where the user can select a record in the form header via a combobox and then build up elements related to the selected record in the detail section of the form. The default view of the form is set to continuous forms.
One of the controls in the detail section of the form is a combobox control. What I want to do is set the enabled property of a textbox on the same row of the form to false based upon a selection from the combobox. The code I am running is:
If Me.cboElementType = "Contract Shrink" Then
Me.txtElementID = ""
Me.txtElementID.Enabled = False
EndIf
This works, but it sets all instances of the textbox (txtElementID) to enabled = false. What I want to have happen is for the txtElementID to have a different enabled setting for each row in the detail section based upon the selection of the combobox cboElementType. So, if cboElementType = "Contract Shrink" on row 1 of the scrolling detail section, the txtElementID.Enabled would be set to false for that row. If cboElementType = "Cost Group" on row 2 of the scrolling detail section, then I'd like txtElementID.Enabled to be False on row 1 of the detail section and txtElementID.Enabled to be True on row 2.
Can anyone confirm or deny that this can be done and, if it can be done, how you would suggest it be accomplished? No matter which way this goes, thanks for help.
You cannot do it through VBA like you did, you need to use Conditional formatting, there you have an option to set the Enabled property.
try in Form_Current() event like
Private Sub Form_Current()
If Me.cboElementType = "Contract Shrink" Then
Me.txtElementID = ""
Me.txtElementID.Enabled = False
EndIf
end sub
I have been searching for days for how to access an individual record on continuous form and I am willing to say it is not possible, but I have a trick that I will share here. I have an investments database, user gets in and writes a proposal and then there is a meeting where either the project is approved (given money) or it is cancelled. However, there are many more states a project can be in, Proposal, Execution, etc. but only Approved/Cancelled can happen at this stage. I created a MockBool field in the Project table. I put that on the continuous form and when the form is closed I run this:
rs_frm=me.recordset
rs_frm.movefirst
while not(rs_frm.eof)
if rs_frm("MockBool") then
rs_frm.edit
rs_frm("ProcessStatus")="Cancelled"
rs_frm("MockBool")=false
rs_frm.update
end if
rs_frm.movenext
wend
I had days of searching and had an epiphany so I thought I would share.

Problem with active status when an continue form have zero record for a filter

this is my first question here and english isnt my language but I'll try to explain at my best.
Im using MS Access 2007.
The form is a "continue form" with a header section where you find an "apply filter" button and a field named "cmpCercaCognome" (italian language for "find surname" plus "cmp" in italian language as field).
This is a cut out of the feature where I am having problems.
The function is fine if the search filter that is set in the field produces at least one result.
The function fails if there are no results.
Private Sub cmpCercaCognome_Change()
If (ActiveControl.Name = "cmpCercaCognome") Then
LunghStr = Len(Me.cmpCercaCognome.Text)
else
LunghStr = Len(Me.cmpCercaCognome)
End if
'Something else but I dont reach it
end sub
The error appear when I'm clicking in the field "cmpCercaCognome" and then Im typing a key there to change the value to use for a filter that I'll apply with a button.
The check "activecontrol" is true still the Len function give error "2185 - Cant read control... without an active status..). How? I just check that have active status! And Im typing just there...
I tryed to modify the IF check so:
"If (ActiveControl.Name = "cmpCercaCognome") And (Me.RecordsetClone.RecordCount > 0) Then"
So I can check just when the count of the record is more than 0.
The problem that so I check the .value of the field that dont contain the last pressed key.
So isnt usefull for me
Is there any way to avoid the problem by keeping control of the temporary value of the field? Or is there a way to make the "temporary value" effective right away so as to avoid checking the .text property?
Thanks for any help you can get on this.

Why does MsAccess Record entry only Update (and show in table) after form close and reopen?

Some Background:
I have a database that acts as a ledger (keeps tabs on current payments).
1:Payments for each customer are stored in one table (PaymentTbl),
2:I have another table (TermAgreementTbl) that holds information on the agreed terms of the service
3: My last table (PdUpToTbl) takes the payment information as well as term agreements information from the two other tables and calculates/displays the information in a clearer manner. One of the ways it will do this, is by deleting the last record in PdUpToTbl, and replacing it, or by just adding a new record (case dependent).
Now MY Issue:
I have a form for my TermAgreementTbl that has a subform showing the relevant PdUpToTbl.
A button opens a pop-up form to enter a new payment and update the related PdUpTotbl.
Everything in the back end is functional, however after I enter a new payment (and save and close the pop-up payment form), NO new record is shown in my PdUpToTbl Subform. Instead it shows something like (some irrelevant info redacted):
For the new record to display properly, I have to close the entire form, and reopen it. There has got to be a way to get around this through vba with some code, right?
Thank you for taking the time.
Edit 1:
By the way, after I perform A LOT of vba code, I use this to enter my record:
With pdUpToRS
.AddNew
![DatePaid] = NewRecordSet.Fields("DatePaid").Value
![Amount] = Amount
![AppliedAmount] = AppliedAmount
![OnAcct] = OnAcct
![AllPdUpTo] = AllPdUpTo
![RemainBalDue] = RemainBalDue
![PdUpToString] = PdUpToString
![PaymentType] = NewRecordSet.Fields("PaymentType").Value
![PaymentNumber] = PaymentNumber
![ID] = NewRecordSet.Fields("ID").Value
![PmntTblID] = PmntTblID
![BdCk] = BdCk
![Late] = Lte
![ApplyDiscount] = ApplyDiscount
![ForgetUnderage] = ForgetUnder
![ForgetOverage] = ForgetOver
![Note] = Note
.Update
End With
Update using requery
I have tried to Requery using:
Forms![MainForm]![Subform].Requery
But it gives me the error:
2118 - - - You must save the current field before you run the Requery action.
And if I add the save line:
DoCmd.RunCommand acCmdSaveRecord
Forms![MainForm]![Subform].Requery
I get the resulting error:
2046 - - - The command or action 'SaveRecord' isn't available now.
Ok, the docmd "menu" options to save a record?
They OFTEN run on the form that has the current focus - so often, then the form you want to save is not the one you expected.
I suggest you replace this:
DoCmd.RunCommand acCmdSaveRecord
with
if me.Dirty then me.Dirty = false
Now, above above "me" is is the current form WHERE that code is running, not some form that might happen to have the focus.
Now, as for a form "requery" (to refresh without close then re-open)?
Again, assuming the above just did the save of the data, then to force a re-load of the current form (again, the form in which the code is running), then:
me.Requery
In fact, if you did not have multiple sub-forms, then a me.refresh would probably work (and a me.Refresh will also save the current record).
So, while the if me.dirty = true then me.dirty = false is about the best way to save the current reocrd in the current form where the code is running?
It is a question of where your code is running, and often when the code is running.
In place of the me.dirty = false, you can also do this, but it often will cause a lot more flicker and refreshing then you want.
But, the shortest code to ensure a save of the forms data, and then requery (same as form close then open), would thus be this:
Me.Refresh
me.Requery
However, often issues can arise if you have some dialog form open - so perhaps a closer look at how your code is updating is often imporant.
But, a me.Requery will re-load everything, but you of course want to ensure you force record saves of the data first.
I think the Requery function will serve you well.
https://learn.microsoft.com/en-us/office/vba/api/access.subform.requery

Copy Value from combo list on login screen to username field on new form

Newer to access...I am trying to copy the value selected from the combobox on the log in screen to a field on the new form that opens after successful login.
The field I need copied is called cmoemployee on the Login form.I need that to go to the username field on the mainframe form.
Any help would be greatly appreciated! I have tried many different ways but I can't seem to get it.
Haha,
I actually know what you mean here. This can be a complete pain as the variables are deleted when you open a new form In general it is better to show what you have tried so people are able to help you fix it. Anyway, I've tried to do this so I know how frustrating it can be. There are two main ways that this can be done. You can open the form with openargs (I do not think this is a good option for you as you will have to have the openargs constantly transferring from one form to the next and will be cleared if one form misses them.
A better option would be to use tempvars which are not deleted. This is the code I used to do something similar:
I am going to assume your combobox is two columns (but only displays one) and the bound column is the primary key to an employee table. In which case this would work (or you can modify it to meet your needs)
Log in:
'Check Password (or however you check it
If StrComp(txt_Password, DLookup("[Password]", "tbl_Employee", "[ID] = " & cmoemployee), 0) = 0 Then
TempVars.Add "MyEmpID", cmoemployee.Value 'TempVars will store the combobox value
Else
Msgbox "Incorrect Password Please try again"
End If
On Load event of mainfraim form:
[UserName] = TempVars!MyEmpID
That should get you started, so you can build the rest. Let me know if you have any questions.

How to open a form at a specific record in Access

I have a form with records for individual people with a button to view/edit a persons clearances. When I finish editing the clearance and press the Back button I want the original form (Basic Personal Information) to open at the record I have just been working on, rather than going back to record 1.
The code I have at present is
DoCmd.Close
DoCmd.OpenForm ("Basic Personal Information")
I have tried changing the OpenForm to
DoCmd.OpenForm ("Basic Personal Information"), , , "S_ID=LinkRef"
Where S_ID is the name of the field which has the persons unique ID and LinkRef is an integer of that ID. I tried a few small variations of this and eventually got it to sort of work, but it opened Basic Personal Information with only that one record available, so I couldn't look at any other people on the form (i.e. in the bottom left record navigation it was 1 of 1, when it should be for example 5 of 32).
Another thing I tried was adding the line
DoCmd.GoToRecord(acDataForm,"Basic Personal Information",acGoTo,"[S_ID] = " & LinkRef)
But obviously, the problem here is that the Offset for AcGoTo should just be a record number, so it should in this case be 5. But I don't know how to tell the program to figure out what number the record will be from the LinkRef.
I hope that makes sense, if not feel free to ask me questions and I will try to explain better, otherwise any suggestions/methods will be appreciated.
Thanks
I would go about your problem this way :
DoCmd.OpenForm ("Basic Personal Information")
Forms("Basic Personal Information").Form.Recordset.FindFirst "[S_ID] = " & _
Forms("PreviousForm").[LinkRef] & ""
Meaning, I would first open the form, and then move the recordset's cursor to the desired row.
maybe this help you: try to open form in dialog:
DoCmd.OpenForm ("Basic Personal Information"), , , , , acDialog
See this page: http://msdn.microsoft.com/en-us/library/bb237964(v=office.12).aspx
I was hoping to find some kind of indexOf() method, but I don't know what the containing class is called. So, here's a work around instead, because I'm not all that familiar with VB:
You can use GoToRecord to go to the first record by passing in 0 for the fourth parameter. Then, loop through all the records using acNext, until you find the entry with the correct S_ID value. Then you can stop there and your entry will be the current one in the list.
It's far from perfect or optimal but it'll work if no other options are presented