Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DAP field creates a new line on enter instead of moving to next field 1

Status
Not open for further replies.

GPM4663

Technical User
Aug 9, 2001
165
GB
Hi Everyone,
I've embarked on using a data access page for users to edit some information of a database. I have the page accepting input OK but when you hit enter the cursor doesn't move to the next tabbed field but tries to create a new line in the current field. If you hit the tab button after inputing it moves to the next field no problem. I would like to alter the "On enter Key behaviour" but have no idea where do it in a DAP.

Many thanks in advance for all your help,

GPM
 
If I remember correctly, when Access creates the field it creates a TestArea control. Something like this <TextArea...></TextArea>. Try changing the TextArea to Input. Like this <Input...>. Remember to remove the </TextArea>. Make a backup copy of your dap before messing with the code though.

The other thing you can do is to trap the Return Key and change it to a Tab key.

One other thing, I messed with dap before and they are a real pain to code. In fact, Microsoft has abandoned dap in Access 2007 (for that reason). I think they have also abandoned the Office Web Components they employ. Also, I believe that if you developed your apps with Access 2003, the user needs a license to run the Office Web Components (owc11.dll). However, the Office Web Components for Access 2000 are freely distributed (owc10.dll). owc10.dll doesn't have some of the same features as owc11.dll, but does include most of them.
 
Hi,
Thanks for your response. You're right the changing the textarea for the field to input stops a new line from being added. Is there anyway to get it to automatically move to the next field in the tab order or will I have to trap the return key like you said?

I agree that DAPs are a nightmare, I can code in VBA all day but just can't get my head around script. The only reason i am using them is because I need to diplay an input screen the same way a grouped report looks and because I can't put a continous form within a continous form in access I'm stuck with DAPs.

Could you help me out with this tab issue. I'd really appreciate it.

cheers,

GPM
 
Try this in the onkeydown event:

Code:
if (window.event.keyCode = 13) then

    window.event.keyCode = 9
    window.event.returnValue = window.event.keycode

end if

However, tab orders are also tricky in daps. Even though you can set the TabIndex so that they are in the order that you want, daps sometimes ingnores them. It seems that daps orders them in the order that they were added to the page.
 
Hi,
Thanks for the response, this is where I run into difficulty. Everytime I try to put the code in place it comes up with a debug error. Here's the entire section of code, could you show me where I am going wrong:

<SCRIPT language=vbscript event=onkeydown for=bookedOut>
<!--if (window.event.keyCode = 13) then
   window.event.keyCode = 9
window.event.returnValue = window.event.keycode
end if

Cheers,

GPM
 
Do you have the </Script> statement at the end of your code?

Try using debugger to step through your code. To use debug you need to go to Internet Options under Tools within IE, then select the Advance tab and be sure Disable Script Debugging (Internet Explorer) is not checked and Display a Notification about every script error is not checked. Then, open your page and when it asks you if you want to debug, say yes. Or place the word Stop above the line of code that's giving you a problem. To step through your code one line at a time, press F11. To continue execution of your code from the current line to the end or the next breakpoint or the word Stop, press F5. To examine the value of variables, either enter them in the Debug Watch window or enter ?variableName in Debug's Immediate window or hold the cursor over the variable (like a tooltip).
 
Hi,
I'm really struggling here. No matter if I put a break point in or the word "STOP" above the line it won't open the page without saying "Error: Invalid character". The line that it points to is the line begining
If window.event....
I have changed the setting about debuggin in windows explorer but it won't let me debug line by line.

Any ideas what character it thinks is invalid?

thanks

GPM
 
I don't use the comment syntax <!--If... Try it without it. Also, sometimes control characters are embedded in the code. Open it in notepad or wordpad to see if you see anything weird.

Finally, add this code and see if it stops for you

Code:
<script language=vbscript>

sub window_onload()
stop
end sub

sub bookedOut_onkeydown()
    stop
    if (window.event.keyCode = 13) then
       window.event.keyCode = 9
       window.event.returnValue = window.event.keycode
    end if
end sub

</script>
 
Hi,
It works!! You must have been right about the embedded control characters because when I repeated the exercise I'd carried out earlier it was finding an error on an allegedly blank line. Once I cleared the line it all worked a treat!
Thanks for all your help and all your patience, I really appreciate it.

thanks again,

GPM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top