Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2010

    Unanswered: A few forms questions

    1) How do I make sure my form opens with no data in it?
    It doesn't at the moment, there's data from the first record in the table or some remnants from the last time I was playing with it. Someone could save the wrong data to a table.

    2) How do I stop the form from stripping out the leading zeros?
    When I key in cus_num 0001, the form displays 1 instead.

    3) I have a combo box fetching values into the form from the Customers table. I want to add a second one that fetches values from the Venues table - but when I add the combo box I'm unable to choose it, it lists Customers as the only available table. How do I fix that?

    4) I want to concatenate FName and LName AS Name. Is 'Name' what I have to use as the field (control) label? In other words, how does the form know which field 'Name' is.

    5) How do I get date pickers to appear on the form?

    6) How do I make all fields compulsory?

    Thanks - rev
    Last edited by revnice; 08-15-10 at 18:26.

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    have you tried adding a record?

    if you open a form with no data how would you expect to be able to show data when you need to?

    I think you cna specify that a form should be open for addign new records (but you will need to set the appropriate values when the form is opened. I don't know what that is, but no doubt google can help

    leading zeros are an attribute of formatting. if you use a numeric value Access trunbcates any leading zeros
    however you should be able to set that as a format in the controls properties
    if the number you want to use s 6 digits long use a format mask of "0000#"

    I cannot think why a combo box can only find one table. if the table is already specified then the combo box designer shoudl find that table... unless you have copied the combo box, rather than created a new one..

    concatenating values is pretty easy

    if length([Title])>0 then PersonsName= [Title]
    if length([Forename])>0 then PersonsName = PersonsName & " " & [Forename]
    if length([Surname])>0 then PersonsName = PersonsName & " " & [Surname]
    if length([Qualifications])>0 then PersonsName = PersonsName & " " & [Qualifications]
    date pickers should be an activex control available to you in form design on the LHS of the screen, it may be that you need to select 'more controls' to find it. this depends on your insatallation. As I run VB, VB.NET and Office I have god knows how many controls which are available in all ennvironments its tough to know what is available in your installation

    you cna't make forms compulsory per se
    however what you can do is place validation code in the forms before update to make certain the controls contain valid values. you cna also place validation code int he columns definition when designing the table.

    to place some validation code open the form in design mode, click on the form (NOT a control), right click and select the code designer

    specify the before update event of the form (if you are a masochist you could specify the before update event of each control

    the test is
    if <thiscontrol> meets this criteria then cancel = false else cancel = true

    say you wanted to make certain that the control had todays date or earlier

    if (cdate(mycontrol.value)>date()) then
    else 'in practise you don't need to set a false value as thats the default
    cancel= false

    you can short circuit that process by avoiding the if
    cancel = (cdate(mycontrol.value)>date())
    ..however that wont work if you have multiple statements in the block (ie put all the validation code into the forms before update event

    .its nice to tell your users why the data cannot be saved, again theres various options
    one is to display an error message, another is to change the background colour or perhaps do both

    for an individual control
    if (cdate(mycontrol.value)>date()) then
    msgbox ("THe specified date:" & mycontrol & " must be less than or equal to todays date", "Oi Muppet", vbwarning)
    else 'in practise you don't need to set a false value as thats the default
    cancel= false

    if (cdate(mycontrol.value)>date()) then
    else 'in practise you don't need to set a false value as thats the default
    cancel= false

    forms before update

    if (length(acontrol.text)==0) then
    strErrorMessage="Something should have a value" & vbcrlf
    if (bcontrol<=10) then
    strErrorMessage="Something should has a value of:" & bcontrol.value & " it should be at least 10" & vbcrlf
    ..... 'add more tests as required
    if cancel=true then msgbox("Errors found" & vbcrlf & strErrorMessage,"Oi Muppet",vbexclamation)

    all the code above is air code.. it hasn't been tested, Im not even certain it will work.. should do but you will need to do some tweaking
    Last edited by healdem; 08-16-10 at 05:24.
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Aug 2010

    >how would you expect to be able to show data when you need to?
    It's a data entry form. Users will enter a Customer number, which retrieve other values from the Customers table. They would add dates from pickers and contact name from a lookup, etc, then it would all somehow magically get saved as a row in the Bookings table. I don't want them accidentally saving the data that first appears. In fact, if I can't easily get a blank form to open, I'll look for another method of making the Booking.

    >Numeric format
    I've got it set too 0000 meaning I want all four digits but that's only happening in the table, the zeros get stripped out in the form. I'll checkout all the formatting possibilities.

    >combo box can only find one table
    I don't know why either. The first box I added worked fine, I was able to choose from the existing tables and then the columns in those tables. The next box I added only shows me the Customers table. Maybe I should copy the first one!

    As for the code, it's over my head at this point but I might get back to you about it. I'm still finding the simplest point-and-click functionality a little baffling.


  4. #4
    Join Date
    Aug 2010

    1) I fixed the leading zeros just by starting with 1000 instead. I can do what I like since it's an arbitrary Customer Number. That fixed that.

    2) The date picker isn't ActiveX. In Design View > select the control > Properties > Data tab > Format row > then drop the little arrow and choose the format there. Bingo, the calendar thingy appears 'onclick.'


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts