I have a database based on the 'Issues.accdb' template, and I want to modify one of the forms.
In the 'Issue Details' form there is an open text box which appends data to a memo 'Comments' field when the record is saved. The history of this comments field is shown in a locked text box below.
I want to change the behaviour of the form so that instead of the user entering a new comment into an open text field on the form, a command button is clicked and it opens an input box; the comment is then input into this.
I also want to enter validation so that no one can enter a blank comment.
The quickest way I could see to rigging what you already have to what you requested would be to do this:
Since you already have a bound memo field for the insertion, just make it invisible. In the onClick event for your command button, you'll just populate that memo field with an InputBox with something like
dim cmt as String
cmt = InputBox("Please provide a comment.")
if cmt = "" then
msgbox("Comments cannot be empty")
else
me.myBoundMemofield = cmt
docmd.save
Related
I have a form with a combo box that has approval codes in it.
I created an AfterUpdate event so that when the user selects the approval code today's date will be placed in another field.
The problem is when I tab out of the combo box the date doesn't display in the field unless I click in that field or save the record.
I know I can do a Me.Refresh after the code, but I don't want to save the record until the user is done with everything they need to input.
Private Sub AppArch_AfterUpdate()
Me.DATE_RCVD_ARCH = Date
End Sub
Must reference textbox name so if field and textbox have same name, then your existing code should work and new value display immediately. Apparently that is not the case. I always name controls different from field, like tbxDateRA. Then code can be:
Me.tbxDateRA = Date
or
Me!tbxDateRA = Date
but use the first to trigger intellisense tips.
I have a checkbox in my main form which causes a text box and a button to disappear and appear when it is not checked and checked respectively. The code below works correctly:
Private Sub Check288_Click()
If Me.Check288.Value = True Then
MsgBox "Please Enter Reference Number and fill in the name", , "Database"
Text293.SetFocus
Me.MTM_Signature.Visible = True
Me.btn_8DGen.Visible = True
Else
Me.MTM_Signature.Visible = False
Me.btn_8DGen.Visible = False
End If
End Sub
My problem is this code is affecting the whole list of records instead of the current chosen record. I have an auto numbered primary key (ID) for identifying each records. Is there any way for me to make the text box and button disappear only for the current record. I am new to access VBA. Thank you.
In the event of Check288_Click() display a modal form and let the user enter the Reference Number. When closing the pop-up form update the database. You can use conditional formatting to hide (blend) the text box if you do not want to show it when empty.
So I am working on a webpage that displays stored information in a form that can be edited. Basically a Requester can enter their contact information which is stored in a database and than can be called by an "editor" who will look over their information and update the request. The issue that I am having is that when I initially populate the form it is setting the value of each textbox to an input and I want to be able to get the changed input in each form to update the database.
This is the code I use to populate the form:
Dim CustomerName As TextBox = DirectCast(RadPanelBar1.FindItemByValue("RequesterInformation").FindControl("txtCustomerName"), TextBox)
CustomerName.Text() = PMPMR.CustomerName
This is the code I use to get the updated information from the form once the editor clicks the approve button:
Dim CustomerName As TextBox = DirectCast(RadPanelBar1.FindItemByValue("RequesterInformation").FindControl("txtCustomerName"), TextBox)
Information.CustomerName = CustomerName.Text
I realize this is a very small sample to show but the code for this webpage is over 800 lines. Thank you!
I have a list box and its row source is "tblitems" with bellow fields.
Now I like when right click on this list box and select one option for example "new task" it opens new task form and automatically Grab the item number from a list box and fills related text box "item number" in "new task" form that is bounded to table "tbltask"
Now when I press "Apply" button it insert new record in "tbltask".
tblItems
item number (pk)
item name (text)
tbltask
task number (auto number,pk)
item number
enter image description here
Getting a value from a list box in a form is:
Me.List_Box_Name.Value
Or if you have unbound values then get it based on the column:
Me.List_Box_Name.Column(2)
or whichever column you need.
You can then populate fields with DLookup or a recordset. Then if you want this to happen when you open a new form, you may want to look into this:
Private Sub Form_Load()
'Stuff you want to happen when that form loads
End Sub
Updated
The following will print out the value each time you click it. You can use this method to trigger a new form to open, or you can have a user click a submit button afterwards.
Private Sub Test_List_Click()
Debug.Print Me.Test_List.Value
DoCmd.OpenForm "Form_Name"
End Sub
Now I'm not exactly sure the best way to add your variable to the opened form. If it were me with my limited knowledge, I would add a global or public string and have the Form_Load() check to see if that string length is greater than 0. If yes then it will populate the field.
Hope that helps
Update 2
Actually this link will help you populate a field from previous form:
MS Access - open a form taking a field value from a previous form
I am using below code to validate the Attachment in Richtext field.
If I will not used Call source.Refresh(True)
then validation is not working, but this code is also refreshing document everytime querysave is called in buttons.
So is there any option or any other idea so that I should not user this Refresh part or entire code to validate .
If anybody have more efficient code then please share this.
If Source.Document.YesNo20(0)="Yes" Then
Call source.Refresh(True)
Dim rtitem As NotesRichTextItem
Set rtitem = source.Document.GetFirstItem( "Atchmnt20" )
NotesEmbeddedObjectArray = rtitem.EmbeddedObjects
If Isempty ( NotesEmbeddedObjectArray ) Then
Messagebox "Please enter an attachment in 20a. As you selected option Yes"
continue=False
Exit Sub
End If
End If
There's a way in LotusScript to check attachments presence even for new (not saved) documents.
Create a hidden computed field, for instance AttachmentNames with formula:
#If(#AttachmentNames!=""; "1"; "");
In LotusScript do the following:
'in new documents Form field may be empty
If doc.Form(0) = "" then
doc.Form = "YourFormAlias"
End If
'computing doc contents with the form
call doc.ComputeWithForm(false, false)
If doc.AttachmentNames(0) = "" then
MsgBox "Please attach a file",,"Attention"
Continue = False 'if you are running this code in QuerySave
Exit Sub
End If
Validating rich text fields in Lotus Notes is a bit of a dark art, but can you not just do this? (where doc is the back-end):
If(doc.HasEmbedded) Then Continue = True
There are other things you can do. Check this Lotus Developer Domain post, which covers attachments, text, embedded objects, all sorts:
http://www-10.lotus.com/ldd/nd6forum.nsf/0/8b3df10667d355768525719a00549058
Can you validate RT field with formula?
I created a hidden field below my rich text field with this Input Validation formula:
REM {Validate just when saving};
#If(!#IsDocBeingSaved; #Return(#Success); "");
REM {Should contain some file};
_filenames := #AttachmentNames;
#If(
#Elements(_filenames)=0;
#Return(#Failure("You should attach at least one file"));
#Success);
Assuming that you want to avoid the Refresh because it takes too long, here is what you may want to look at and if feasible, try to change:
Maybe you can use the "Entering" event of the RichText field in conjunction with a global variable (in the form) to skip the Refresh in your code, if the RichText field wasn't touched at all.
Are there keyword fields with "Refresh choices on document refresh" option enabled that may be safe to disable? Or even place a button that would bring up a dialog and populate the field with the selected keyword(s) - refreshing the choices won't be neccessary then, as you can always present up-to-date choices through #DbColumn/#DbLookup or NotesUIWorkspace.PickListStrings.
Is there any code (LotusScript or Formula) in "Queryrecalc" and/or "Postrecalc" form events that may be possible to optimize? For example by using a global variable (in the form) as a flag whether to execute the code in Queryrecalc/Postrecalc - set it to false just before calling Refresh in your code, then set it back to true (because this Refresh only serves to update the RichText field to the backend document).